From 5d3093f8c79e54827864b04ec6b470488d72c960 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 22 Jan 2023 12:50:17 +0000 Subject: test: nsgif: Add CLI option to print version --- test/nsgif.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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; @@ -70,6 +74,14 @@ static const struct cli_table_entry cli_entries[] = { .v.b = &nsgif_options.palette, .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", @@ -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) { -- cgit v1.2.1