Skip to content

Commit

Permalink
Add command list to -h output
Browse files Browse the repository at this point in the history
Addresses #15
  • Loading branch information
wez committed Apr 20, 2014
1 parent 32b9528 commit 3193404
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
11 changes: 10 additions & 1 deletion listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,16 @@ static struct watchman_command_handler_def commands[] = {
{ NULL, NULL }
};

void print_command_list_for_help(FILE *where)
{
int i;

fprintf(where, "\n\nAvailable commands:\n\n");
for (i = 0; commands[i].name; i++) {
fprintf(where, " %s\n", commands[i].name);
}
}

void register_commands(struct watchman_command_handler_def *defs)
{
int i;
Expand Down Expand Up @@ -896,4 +906,3 @@ bool w_start_listener(const char *path)

/* vim:ts=2:sw=2:et:
*/

7 changes: 5 additions & 2 deletions opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ void usage(struct watchman_getopt *opts, FILE *where)
fprintf(where, "\n");
}

print_command_list_for_help(where);

fprintf(where,
"\n"
"See https://github.com/facebook/watchman#watchman for more help\n"
"\n"
"Watchman, by Wez Furlong.\n"
"Copyright 2012-2013 Facebook, Inc.\n"
"Copyright 2012-2014 Facebook, Inc.\n"
);

exit(1);
Expand Down Expand Up @@ -249,4 +253,3 @@ bool w_getopt(struct watchman_getopt *opts, int *argcp, char ***argvp,

/* vim:ts=2:sw=2:et:
*/

2 changes: 1 addition & 1 deletion watchman.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ struct watchman_getopt {
bool w_getopt(struct watchman_getopt *opts, int *argcp, char ***argvp,
char ***daemon_argv);
void usage(struct watchman_getopt *opts, FILE *where);
void print_command_list_for_help(FILE *where);

struct w_clockspec *w_clockspec_new_clock(uint32_t root_number, uint32_t ticks);
struct w_clockspec *w_clockspec_parse(json_t *value);
Expand Down Expand Up @@ -757,4 +758,3 @@ struct watchman_client_subscription {

/* vim:ts=2:sw=2:et:
*/

0 comments on commit 3193404

Please sign in to comment.