summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd.c6
-rw-r--r--cli/src/cli.c17
-rw-r--r--cli/src/cli.h13
3 files changed, 33 insertions, 3 deletions
diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c
index 396cabebbbe..2ee8b1b4968 100644
--- a/cli/src/cli-cmd.c
+++ b/cli/src/cli-cmd.c
@@ -108,12 +108,14 @@ cli_cmd_process(struct cli_state *state, int argc, char **argv)
}
if (!word) {
- cli_out("unrecognized word: %s (position %d)", argv[i], i);
+ cli_out("unrecognized word: %s (position %d)\n", argv[i], i);
+ usage();
return -1;
}
if (!word->cbkfn) {
- cli_out("unrecognized command");
+ cli_out("unrecognized command\n");
+ usage();
return -1;
}
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 3716d2a89ca..99fe6f1612c 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -320,6 +320,20 @@ cli_opt_parse(char *opt, struct cli_state *state)
if (strcmp(opt, "") == 0)
return 1;
+ if (strcmp(opt, "help") == 0) {
+ cli_out(
+ " peer help - display help for peer commands\n"
+ " volume help - display help for volume commands\n"
+ " volume bitrot help - display help for volume"
+ " bitrot commands\n"
+ " volume quota help - display help for volume"
+ " quota commands\n"
+ " volume tier help - display help for volume"
+ " tier commands\n"
+ " snapshot help - display help for snapshot commands\n"
+ " global help - list global commands\n");
+ exit(0);
+ }
if (strcmp(opt, "version") == 0) {
cli_out("%s", argp_program_version);
@@ -454,7 +468,8 @@ parse_cmdline(int argc, char *argv[], struct cli_state *state)
continue;
ret = cli_opt_parse(opt, state);
if (ret == -1) {
- cli_out("unrecognized option --%s", opt);
+ cli_out("unrecognized option --%s\n", opt);
+ usage();
return ret;
} else if (ret == -2) {
return ret;
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 773297e4be8..2c2b4355111 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -239,6 +239,19 @@ _cli_err(const char *fmt, ...);
\
} while (0)
+#define usage() \
+ do { \
+ cli_out( \
+ " Usage: gluster [options] <help> <peer>" \
+ " <pool> <volume>\n" \
+ " Options:\n" \
+ " --help Shows the help information\n" \
+ " --version Shows the version\n" \
+ " --print-logdir Shows the log directory\n" \
+ " --print-statedumpdir Shows the state dump directory\n"); \
+ \
+ } while (0)
+
int
cli_submit_request(struct rpc_clnt *rpc, void *req, call_frame_t *frame,
rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref,