]> Untitled Git - mpdstream/commitdiff
Add manual --version option
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 31 Mar 2026 01:16:23 +0000 (21:16 -0400)
committerHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 31 Mar 2026 20:34:21 +0000 (16:34 -0400)
Using ARGP_NO_HELP disables all of the default automatic options
including "--version". Manually add the "--version" option.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
src/options.c

index fab192b89cf37169b0f357afb3f5522b3c72c679..22b930f33892b2d7b04a20bb10f0f2d404f2ddad 100644 (file)
@@ -62,6 +62,7 @@ static struct argp_option argp_options[] = {
        {"host",  's', "host", 0, "MPD server address/hostname", 0},
        {"help",  'h', 0,  0, "Give this help list", -1},
        {"usage", USAGE_KEY, 0,    0, "Give a short usage message", -1},
+       {"version", 'V', 0, 0, "Print program version", 0},
        { 0 }
 };
 
@@ -116,6 +117,9 @@ parse_opt(int key, char *arg, struct argp_state *state)
        case 't':
                decode_int(arg, state, &options.start_delay);
                break;
+       case 'V':
+               printf("%s\n", argp_program_version);
+               exit(0);
         case USAGE_KEY:
                argp_state_help(state, state->out_stream, ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
                exit(0);