From 943ae3ce239371cd33eaa1033f580aca787ef1b9 Mon Sep 17 00:00:00 2001 From: Ricky Elrod Date: Fri, 31 May 2013 05:07:50 -0400 Subject: [PATCH] Add a --version flag that prints PACKAGE_VERSION. This is useful for help2man to add the version at the top of the generated manpage. --- main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.c b/main.c index 6f42b506d2f9..2536f80aae9d 100644 --- a/main.c +++ b/main.c @@ -7,6 +7,7 @@ int trigger_settle = DEFAULT_SETTLE_PERIOD; int recrawl_period = 0; static int show_help = 0; +static int show_version = 0; static enum w_pdu_type server_pdu = is_bser; static enum w_pdu_type output_pdu = is_json_pretty; static char *server_encoding = NULL; @@ -326,6 +327,8 @@ static bool try_command(json_t *cmd, int timeout) static struct watchman_getopt opts[] = { { "help", 'h', "Show this help", OPT_NONE, &show_help, NULL, NOT_DAEMON }, + { "version", 0, "Show version number", + OPT_NONE, &show_version, NULL, NOT_DAEMON }, { "sockname", 'U', "Specify alternate sockname", REQ_STRING, &sock_name, "PATH", IS_DAEMON }, { "logfile", 'o', "Specify path to logfile", @@ -372,6 +375,10 @@ static void parse_cmdline(int *argcp, char ***argvp) if (show_help) { usage(opts, stdout); } + if (show_version) { + printf("%s\n", PACKAGE_VERSION); + exit(0); + } setup_sock_name(); parse_encoding(server_encoding, &server_pdu); parse_encoding(output_encoding, &output_pdu);