Skip to content

Commit 502b136

Browse files
committed
gpujpegtool: add --fullhelp/-H to show all options
hide --debug/-a
1 parent 5640888 commit 502b136

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/main.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@
4545
#define USE_IF_NOT_NULL_ELSE(cond, alt_val) (cond) ? (cond) : (alt_val)
4646

4747
static void
48-
print_help(void)
48+
print_help(bool full)
4949
{
5050
printf("gpujpegtool [options] input.rgb output.jpg [input2.rgb output2.jpg ...]\n"
5151
" -h, --help print help\n"
5252
" -v, --verbose verbose output (multiply to increase verbosity - max 3) \n"
53-
" -b, --debug debug helpers (reset GPU for leakcheck, dump infile if not regular)\n"
5453
" -D, --device set cuda device id (default 0)\n"
5554
" -L, --device-list list cuda devices\n"
5655
"\n");
@@ -85,6 +84,12 @@ print_help(void)
8584
" works also for decoding)\n"
8685
" -V --version print GPUJPEG version\n"
8786
);
87+
if ( full ) {
88+
printf(" -b, --debug debug helpers (reset GPU for leakcheck, dump infile if not regular)\n");
89+
}
90+
else {
91+
printf(" -H, --fullhelp print all options\n");
92+
}
8893
printf("recognized raw input/output file extensions: rgb, yuv, pnm... (use`gpujpegtool exts` for the full list)\n");
8994
}
9095

@@ -320,6 +325,7 @@ main(int argc, char *argv[])
320325
{"alpha", no_argument, 0, 'a'},
321326
{"debug", no_argument, 0, 'b'},
322327
{"help", no_argument, 0, 'h'},
328+
{"fullhelp", no_argument, 0, 'H'},
323329
{"verbose", optional_argument, 0, 'v'},
324330
{"device", required_argument, 0, 'D'},
325331
{"device-list", no_argument, 0, 'L' },
@@ -345,13 +351,16 @@ main(int argc, char *argv[])
345351
int ch = '\0';
346352
int optindex = 0;
347353
char* pos = 0;
348-
while ( (ch = getopt_long(argc, argv, "CD:I:LNRS::Vabc:edf:ghin:oq:r:s:v", longopts, &optindex)) != -1 ) {
354+
while ( (ch = getopt_long(argc, argv, "CD:HI:LNRS::Vabc:edf:ghin:oq:r:s:v", longopts, &optindex)) != -1 ) {
349355
switch (ch) {
350356
case 'a':
351357
opts.keep_alpha = true;
352358
break;
353359
case 'h':
354-
print_help();
360+
print_help(false);
361+
return 0;
362+
case 'H':
363+
print_help(true);
355364
return 0;
356365
case 'v':
357366
if (optarg) {
@@ -460,7 +469,7 @@ main(int argc, char *argv[])
460469
return -1;
461470
default:
462471
fprintf(stderr, "Unrecognized option '%c' (code 0%o)\n", ch, ch);
463-
print_help();
472+
print_help(false);
464473
return -1;
465474
}
466475
}
@@ -488,7 +497,7 @@ main(int argc, char *argv[])
488497
// Source image and target image must be presented
489498
if ( argc < 2 || argc % 2 != 0 ) {
490499
fprintf(stderr, "Please supply source and destination image filename(s)!\n");
491-
print_help();
500+
print_help(false);
492501
return -1;
493502
}
494503

0 commit comments

Comments
 (0)