Skip to content

Commit

Permalink
Add a --version flag that prints PACKAGE_VERSION.
Browse files Browse the repository at this point in the history
This is useful for help2man to add the version at the top of the
generated manpage.
  • Loading branch information
relrod committed May 31, 2013
1 parent 2382de4 commit 943ae3c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 943ae3c

Please sign in to comment.