summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-misc.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-08-17 03:37:46 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-17 02:23:59 -0700
commite5737546071bd1d38430503bb64b9998bd7870dd (patch)
treec5a9fe82f2474ff6c8792381c1b77384c9f82983 /cli/src/cli-cmd-misc.c
parentead92558ee8ec71442b2fa2da1a0df197ee78467 (diff)
cli: Implement help command
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1229 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1229
Diffstat (limited to 'cli/src/cli-cmd-misc.c')
-rw-r--r--cli/src/cli-cmd-misc.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-misc.c b/cli/src/cli-cmd-misc.c
index 9e78ca607..1c99bf930 100644
--- a/cli/src/cli-cmd-misc.c
+++ b/cli/src/cli-cmd-misc.c
@@ -37,6 +37,11 @@ extern struct rpc_clnt *global_rpc;
extern rpc_clnt_prog_t *cli_rpc_prog;
+extern struct cli_cmd volume_cmds[];
+extern struct cli_cmd cli_probe_cmds[];
+extern struct cli_cmd cli_log_cmds[];
+struct cli_cmd cli_misc_cmds[];
+
int
cli_cmd_quit_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
@@ -44,12 +49,40 @@ cli_cmd_quit_cbk (struct cli_state *state, struct cli_cmd_word *word,
exit (0);
}
+int
+cli_cmd_display_help (struct cli_state *state, struct cli_cmd_word *in_word,
+ const char **words, int wordcount)
+{
+ struct cli_cmd *cmd = NULL;
+
+ for (cmd = volume_cmds; cmd->pattern; cmd++)
+ cli_out ("%s - %s", cmd->pattern, cmd->desc);
+
+ for (cmd = cli_probe_cmds; cmd->pattern; cmd++)
+ cli_out ("%s - %s", cmd->pattern, cmd->desc);
+
+ for (cmd = cli_log_cmds; cmd->pattern; cmd++)
+ cli_out ("%s - %s", cmd->pattern, cmd->desc);
+
+ for (cmd = cli_misc_cmds; cmd->pattern; cmd++)
+ cli_out ("%s - %s", cmd->pattern, cmd->desc);
+
+ if (!state->rl_enabled)
+ exit (0);
+
+ return 0;
+}
+
struct cli_cmd cli_misc_cmds[] = {
{ "quit",
- cli_cmd_quit_cbk },
+ cli_cmd_quit_cbk,
+ "quit"},
+ { "help",
+ cli_cmd_display_help,
+ "display command options"},
- { NULL, NULL }
+ { NULL, NULL, NULL }
};
@@ -60,7 +93,8 @@ cli_cmd_misc_register (struct cli_state *state)
struct cli_cmd *cmd = NULL;
for (cmd = cli_misc_cmds; cmd->pattern; cmd++) {
- ret = cli_cmd_register (&state->tree, cmd->pattern, cmd->cbk);
+ ret = cli_cmd_register (&state->tree, cmd->pattern, cmd->cbk,
+ cmd->desc);
if (ret)
goto out;
}