diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2010-08-25 02:09:06 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-08-25 02:08:50 -0700 |
commit | c83b6f73f08eb81788dd1fe35c461b19dc9405df (patch) | |
tree | 184655e7d26327c5636e6cddb4c702b33b867d5f | |
parent | 606cf3e291029169ec8154dec52c9b5ec6afc455 (diff) |
cli: print usage message when parsing of cmd fails
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1432 (print usage string in case of command parse errors)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1432
-rw-r--r-- | cli/src/cli-cmd-volume.c | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 283233cf9..92307ceb3 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -332,6 +332,12 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct cli_cmd_word *word, return 0; } +void +cli_cmd_volume_add_brick_usage () +{ + cli_out ("usage: volume add-brick <VOLNAME> " + "[(replica <COUNT>)|(stripe <COUNT>)] <NEW-BRICK> ..."); +} int cli_cmd_volume_add_brick_cbk (struct cli_state *state, @@ -349,8 +355,11 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state, ret = cli_cmd_volume_add_brick_parse (words, wordcount, &options); - if (ret) + if (ret) { + printf("Command Parsing failed, "); + cli_cmd_volume_add_brick_usage (); goto out; + } proc = &cli_rpc_prog->proctable[GF1_CLI_ADD_BRICK]; @@ -360,13 +369,22 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state, out: if (!proc && ret) { - char *volname = (char *) words[2]; - cli_out ("Adding brick to Volume %s failed",volname ); + if (wordcount > 2) { + char *volname = (char *) words[2]; + cli_out ("Adding brick to Volume %s failed",volname ); + } } return ret; } +void +cli_cmd_volume_remove_brick_usage () +{ + cli_out ("usage: volume remove-brick <VOLNAME> " + "[(replica <COUNT>)|(stripe <COUNT>)] <BRICK> ..."); +} + int cli_cmd_volume_remove_brick_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, @@ -383,8 +401,11 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, ret = cli_cmd_volume_remove_brick_parse (words, wordcount, &options); - if (ret) + if (ret) { + printf("Command Parsing failed, "); + cli_cmd_volume_remove_brick_usage (); goto out; + } proc = &cli_rpc_prog->proctable[GF1_CLI_REMOVE_BRICK]; @@ -394,14 +415,21 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, out: if (!proc && ret) { - char *volname = (char *) words[2]; - cli_out ("Removing brick from Volume %s failed",volname ); + if (wordcount > 2) { + char *volname = (char *) words[2]; + cli_out ("Removing brick from Volume %s failed",volname ); + } } return ret; } - +void +cli_cmd_volume_replace_brick_usage () +{ + cli_out("usage: volume replace-brick <VOLNAME> " + "(<BRICK> <NEW-BRICK>)|pause|abort|start|status"); +} int @@ -423,8 +451,11 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state, ret = cli_cmd_volume_replace_brick_parse (words, wordcount, &options); - if (ret) + if (ret) { + printf("Command Parsing failed, "); + cli_cmd_volume_replace_brick_usage (); goto out; + } if (proc->fn) { ret = proc->fn (frame, THIS, options); @@ -432,8 +463,10 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state, out: if (ret) { - char *volname = (char *) words[2]; - cli_out ("Replacing brick from Volume %s failed",volname ); + if (wordcount > 2) { + char *volname = (char *) words[2]; + cli_out ("Replacing brick from Volume %s failed",volname ); + } } return ret; |