diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2023-01-22 12:50:17 +0000 |
---|---|---|
committer | Michael Drake <mdrake.unique@gmail.com> | 2023-01-22 12:52:59 +0000 |
commit | 5d3093f8c79e54827864b04ec6b470488d72c960 (patch) | |
tree | b2d65cf04788a4751a8d86391392ac6a67d333a0 | |
parent | 0451fa34f6c88eb7e53bdc3762e37ff1f0c0927a (diff) | |
download | libnsgif-5d3093f8c79e54827864b04ec6b470488d72c960.tar.gz libnsgif-5d3093f8c79e54827864b04ec6b470488d72c960.tar.bz2 |
test: nsgif: Add CLI option to print version
-rw-r--r-- | test/nsgif.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/nsgif.c b/test/nsgif.c index f873bab..16a4bc9 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -21,6 +21,9 @@ #include "cli.h" #include "cli.c" +#define STR_VAL(_S) STR(_S) +#define STR(_S) #_S + #define BYTES_PER_PIXEL 4 static struct nsgif_options { @@ -28,6 +31,7 @@ static struct nsgif_options { const char *ppm; uint64_t loops; bool palette; + bool version; bool info; bool help; } nsgif_options; @@ -71,6 +75,14 @@ static const struct cli_table_entry cli_entries[] = { .d = "Save palette images." }, { + .s = 'V', + .l = "version", + .t = CLI_BOOL, + .no_pos = true, + .v.b = &nsgif_options.version, + .d = "Print version number." + }, + { .p = true, .l = "FILE", .t = CLI_STRING, @@ -372,6 +384,11 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } + if (nsgif_options.version) { + printf("%s %s\n", STR_VAL(NSGIF_NAME), STR_VAL(NSGIF_VERSION)); + return EXIT_SUCCESS; + } + if (nsgif_options.ppm != NULL) { ppm = fopen(nsgif_options.ppm, "w+"); if (ppm == NULL) { |