Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a --version flag that prints PACKAGE_VERSION. #3

Merged
merged 1 commit into from
May 31, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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