From d4e69fcebd776233c42ef044230ce3b5b83e61de Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 1 Jan 2023 17:59:55 +0000 Subject: test: Add --help option to nsgif utility --- test/nsgif.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/test/nsgif.c b/test/nsgif.c index 53c6a68..f873bab 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -29,15 +29,17 @@ static struct nsgif_options { uint64_t loops; bool palette; bool info; + bool help; } nsgif_options; static const struct cli_table_entry cli_entries[] = { { - .s = 'm', - .l = "ppm", - .t = CLI_STRING, - .v.s = &nsgif_options.ppm, - .d = "Convert frames to PPM image at given path." + .s = 'h', + .l = "help", + .t = CLI_BOOL, + .no_pos = true, + .v.b = &nsgif_options.help, + .d = "Print this text.", }, { .s = 'i', @@ -54,6 +56,13 @@ static const struct cli_table_entry cli_entries[] = { .d = "Loop through decoding all frames N times. " "The default is 1." }, + { + .s = 'm', + .l = "ppm", + .t = CLI_STRING, + .v.s = &nsgif_options.ppm, + .d = "Convert frames to PPM image at given path." + }, { .s = 'p', .l = "palette", @@ -358,6 +367,11 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + if (nsgif_options.help) { + cli_help(&cli, argv[0]); + return EXIT_SUCCESS; + } + if (nsgif_options.ppm != NULL) { ppm = fopen(nsgif_options.ppm, "w+"); if (ppm == NULL) { -- cgit v1.2.1