Skip to content

Commit ed993ec

Browse files
committed
[General] Add 'html-hljs' option to -m/--color
1 parent 125ea3c commit ed993ec

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Sources/classdumpctl/main.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ typedef NS_ENUM(NSUInteger, CDOutputColorMode) {
1818
CDOutputColorModeDefault,
1919
CDOutputColorModeNever,
2020
CDOutputColorModeAlways,
21+
CDOutputColorModeHtmlHljs,
2122

2223
CDOutputColorModeCaseCount
2324
};
@@ -36,9 +37,10 @@ static void printUsage(const char *progname) {
3637
" the specified directory, otherwise all classes found\n"
3738
" are written to this directory at the top level\n"
3839
" -m <m>, --color=<m> Set color settings, one of the below\n"
39-
" default: color output only if output is to a TTY\n"
40+
" default: color output using ASNI color escapes only if output is to a TTY\n"
4041
" never: no output is colored\n"
41-
" always: output to TTYs, pipes, and files are colored\n"
42+
" always: output to TTYs, pipes, and files are colored using ASNI color escapes\n"
43+
" html-hljs: output to TTYs, pipes, and files are in HTML format annotated with hljs classes\n"
4244
" -i <p>, --image=<p> Reference the mach-o image at path\n"
4345
" by default, dump all classes in this image\n"
4446
" otherwise may specify --class or --protocol\n"
@@ -183,6 +185,8 @@ static void printUsage(const char *progname) {
183185
case CDOutputColorModeAlways:
184186
shouldColor = YES;
185187
break;
188+
case CDOutputColorModeHtmlHljs:
189+
return hljsHtmlForSemanticString(semanticString);
186190
default:
187191
NSCAssert(NO, @"Unknown case: %lu", (unsigned long)colorMode);
188192
break;
@@ -236,8 +240,14 @@ int main(int argc, char *argv[]) {
236240
outputColorMode = CDOutputColorModeDefault;
237241
} else if (strcmp(stringyOption, "never") == 0) {
238242
outputColorMode = CDOutputColorModeNever;
243+
} else if (strcmp(stringyOption, "none") == 0) { // alias
244+
outputColorMode = CDOutputColorModeNever;
239245
} else if (strcmp(stringyOption, "always") == 0) {
240246
outputColorMode = CDOutputColorModeAlways;
247+
} else if (strcmp(stringyOption, "ansi") == 0) { // alias
248+
outputColorMode = CDOutputColorModeAlways;
249+
} else if (strcmp(stringyOption, "html-hljs") == 0) {
250+
outputColorMode = CDOutputColorModeHtmlHljs;
241251
} else {
242252
printUsage(argv[0]);
243253
return 1;

0 commit comments

Comments
 (0)