a3470f
From fb84f6c69385e35f3a62504dfebc11b21ff4082a Mon Sep 17 00:00:00 2001
a3470f
From: N Balachandran <nbalacha@redhat.com>
a3470f
Date: Mon, 6 Nov 2017 09:30:54 +0530
a3470f
Subject: [PATCH 075/128] cli: gluster help changes
a3470f
a3470f
gluster cli help now shows only the top level
a3470f
help commands. gluster <component> help will now show
a3470f
help commands for <component>.
a3470f
a3470f
> BUG: 1474768
a3470f
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
a3470f
> BUG: 1509786
a3470f
> https://review.gluster.org/#/c/18666/
a3470f
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
a3470f
a3470f
(cherry picked from commit 89dc54f50c9f800ca4446ea8fe736e4860588845)
a3470f
Change-Id: I263f53a0870d80ef4cfaad455fdaa47e2ac4423b
a3470f
BUG: 1498730
a3470f
Signed-off-by: N Balachandran <nbalacha@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/123525
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
---
a3470f
 cli/src/cli-cmd-global.c   |   3 +
a3470f
 cli/src/cli-cmd-misc.c     |  77 ++++++++--
a3470f
 cli/src/cli-cmd-parser.c   |  20 ++-
a3470f
 cli/src/cli-cmd-peer.c     |   9 +-
a3470f
 cli/src/cli-cmd-snapshot.c |   5 +
a3470f
 cli/src/cli-cmd-volume.c   | 347 ++++++++++++++++++++++++++++++++++++++-------
a3470f
 cli/src/cli.c              |   2 +-
a3470f
 7 files changed, 387 insertions(+), 76 deletions(-)
a3470f
a3470f
diff --git a/cli/src/cli-cmd-global.c b/cli/src/cli-cmd-global.c
a3470f
index 881506b..1f9cb54 100644
a3470f
--- a/cli/src/cli-cmd-global.c
a3470f
+++ b/cli/src/cli-cmd-global.c
a3470f
@@ -68,11 +68,14 @@ cli_cmd_global_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
         count = (sizeof (global_cmds) / sizeof (struct cli_cmd));
a3470f
         cli_cmd_sort (cmd, count);
a3470f
 
a3470f
+        cli_out ("\ngluster global commands");
a3470f
+        cli_out ("========================\n");
a3470f
         for (global_cmd = cmd; global_cmd->pattern; global_cmd++)
a3470f
                 if (_gf_false == global_cmd->disable)
a3470f
                         cli_out ("%s - %s", global_cmd->pattern,
a3470f
                                  global_cmd->desc);
a3470f
 
a3470f
+        cli_out ("\n");
a3470f
         GF_FREE (cmd);
a3470f
         return 0;
a3470f
 }
a3470f
diff --git a/cli/src/cli-cmd-misc.c b/cli/src/cli-cmd-misc.c
a3470f
index 9f8c159..c887515 100644
a3470f
--- a/cli/src/cli-cmd-misc.c
a3470f
+++ b/cli/src/cli-cmd-misc.c
a3470f
@@ -23,6 +23,9 @@ extern struct rpc_clnt *global_rpc;
a3470f
 extern rpc_clnt_prog_t *cli_rpc_prog;
a3470f
 
a3470f
 extern struct cli_cmd volume_cmds[];
a3470f
+extern struct cli_cmd bitrot_cmds[];
a3470f
+extern struct cli_cmd quota_cmds[];
a3470f
+extern struct cli_cmd tier_cmds[];
a3470f
 extern struct cli_cmd cli_probe_cmds[];
a3470f
 extern struct cli_cmd cli_log_cmds[];
a3470f
 extern struct cli_cmd cli_system_cmds[];
a3470f
@@ -38,37 +41,76 @@ cli_cmd_quit_cbk (struct cli_state *state, struct cli_cmd_word *word,
a3470f
         exit (0);
a3470f
 }
a3470f
 
a3470f
+
a3470f
+static gf_boolean_t
a3470f
+cli_is_help_command (const char *pattern)
a3470f
+{
a3470f
+        /* FixFixFix
a3470f
+         * This is not the best way to determine whether
a3470f
+         * this is a help command
a3470f
+         */
a3470f
+        if (strstr (pattern, "help"))
a3470f
+                return _gf_true;
a3470f
+
a3470f
+        return _gf_false;
a3470f
+}
a3470f
+
a3470f
+
a3470f
 int
a3470f
 cli_cmd_display_help (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
                       const char **words, int wordcount)
a3470f
 {
a3470f
-        struct cli_cmd        *cmd[] = {volume_cmds, cli_probe_cmds,
a3470f
-                                       cli_misc_cmds, snapshot_cmds,
a3470f
-                                       global_cmds, NULL};
a3470f
-        struct cli_cmd        *cmd_ind = NULL;
a3470f
-        int                   i = 0;
a3470f
+        struct cli_cmd        *cmd[] = {cli_misc_cmds, cli_probe_cmds,
a3470f
+                                        volume_cmds, bitrot_cmds, quota_cmds,
a3470f
+#if !defined(__NetBSD__)
a3470f
+                                        tier_cmds,
a3470f
+#endif
a3470f
+                                        snapshot_cmds, global_cmds, NULL};
a3470f
+        struct cli_cmd        *cmd_ind      = NULL;
a3470f
+        int                    i            = 0;
a3470f
+        gf_boolean_t           list_all     = _gf_false;
a3470f
 
a3470f
          /* cli_system_cmds commands for internal usage
a3470f
            they are not exposed
a3470f
          */
a3470f
-        for (i=0; cmd[i]!=NULL; i++)
a3470f
-                for (cmd_ind = cmd[i]; cmd_ind->pattern; cmd_ind++)
a3470f
-                        if (_gf_false == cmd_ind->disable)
a3470f
-                                cli_out ("%s - %s", cmd_ind->pattern,
a3470f
-                                         cmd_ind->desc);
a3470f
 
a3470f
+        /* If "help all" */
a3470f
+        if (wordcount == 2)
a3470f
+                list_all = _gf_true;
a3470f
+
a3470f
+        for (i = 0; cmd[i] != NULL; i++) {
a3470f
+                for (cmd_ind = cmd[i]; cmd_ind->pattern; cmd_ind++) {
a3470f
+                        if ((_gf_false == cmd_ind->disable) &&
a3470f
+                            cli_is_help_command (cmd_ind->pattern)) {
a3470f
+                                if (list_all && (cmd_ind->cbk)) {
a3470f
+                                        cmd_ind->cbk (state, in_word, words,
a3470f
+                                                      wordcount);
a3470f
+                                } else {
a3470f
+                                        cli_out (" %-25s- %s", cmd_ind->pattern,
a3470f
+                                                 cmd_ind->desc);
a3470f
+                                }
a3470f
+                        }
a3470f
+                }
a3470f
+        }
a3470f
+
a3470f
+        cli_out ("\n");
a3470f
         return 0;
a3470f
 }
a3470f
 
a3470f
+
a3470f
+struct cli_cmd cli_help_cmds[] = {
a3470f
+        { "help [all]",
a3470f
+           cli_cmd_display_help,
a3470f
+           "display help for command classes"},
a3470f
+
a3470f
+        { NULL, NULL, NULL }
a3470f
+};
a3470f
+
a3470f
+
a3470f
 struct cli_cmd cli_misc_cmds[] = {
a3470f
         { "quit",
a3470f
           cli_cmd_quit_cbk,
a3470f
           "quit"},
a3470f
-
a3470f
-        { "help",
a3470f
-           cli_cmd_display_help,
a3470f
-           "display command options"},
a3470f
-
a3470f
         { "exit",
a3470f
           cli_cmd_quit_cbk,
a3470f
           "exit"},
a3470f
@@ -84,7 +126,12 @@ cli_cmd_misc_register (struct cli_state *state)
a3470f
         struct cli_cmd *cmd = NULL;
a3470f
 
a3470f
         for (cmd = cli_misc_cmds; cmd->pattern; cmd++) {
a3470f
+                ret = cli_cmd_register (&state->tree, cmd);
a3470f
+                if (ret)
a3470f
+                        goto out;
a3470f
+        }
a3470f
 
a3470f
+        for (cmd = cli_help_cmds; cmd->pattern; cmd++) {
a3470f
                 ret = cli_cmd_register (&state->tree, cmd);
a3470f
                 if (ret)
a3470f
                         goto out;
a3470f
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
a3470f
index a35fc74..c95b262 100644
a3470f
--- a/cli/src/cli-cmd-parser.c
a3470f
+++ b/cli/src/cli-cmd-parser.c
a3470f
@@ -1189,8 +1189,13 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options)
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
-        if (wordcount < 4)
a3470f
+        if (wordcount < 4) {
a3470f
+
a3470f
+                if ((wordcount == 3) && !(strcmp (words[2], "help"))) {
a3470f
+                        ret = 1;
a3470f
+                }
a3470f
                 goto out;
a3470f
+        }
a3470f
 
a3470f
         volname = (char *)words[2];
a3470f
         if (!volname) {
a3470f
@@ -5588,15 +5593,22 @@ cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **options)
a3470f
         GF_ASSERT (words);
a3470f
         GF_ASSERT (options);
a3470f
 
a3470f
-        dict = dict_new ();
a3470f
-        if (!dict)
a3470f
-                goto out;
a3470f
+
a3470f
+        /* Hack to print out bitrot help properly */
a3470f
+        if ((wordcount == 3) && !(strcmp (words[2], "help"))) {
a3470f
+                ret = 1;
a3470f
+                return ret;
a3470f
+        }
a3470f
 
a3470f
         if (wordcount < 4 || wordcount > 5) {
a3470f
                 gf_log ("cli", GF_LOG_ERROR, "Invalid syntax");
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
+        dict = dict_new ();
a3470f
+        if (!dict)
a3470f
+                goto out;
a3470f
+
a3470f
         volname = (char *)words[2];
a3470f
         if (!volname) {
a3470f
                 ret = -1;
a3470f
diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
a3470f
index 4802f71..7df60bc 100644
a3470f
--- a/cli/src/cli-cmd-peer.c
a3470f
+++ b/cli/src/cli-cmd-peer.c
a3470f
@@ -264,7 +264,7 @@ struct cli_cmd cli_probe_cmds[] = {
a3470f
 
a3470f
 	{ "peer help",
a3470f
            cli_cmd_peer_help_cbk,
a3470f
-           "Help command for peer "},
a3470f
+           "display help for peer commands"},
a3470f
 
a3470f
         { "pool list",
a3470f
           cli_cmd_pool_list_cbk,
a3470f
@@ -281,17 +281,20 @@ cli_cmd_peer_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
         struct cli_cmd        *probe_cmd = NULL;
a3470f
         int                   count     = 0;
a3470f
 
a3470f
+        cli_out ("\ngluster peer commands");
a3470f
+        cli_out ("======================\n");
a3470f
+
a3470f
         cmd = GF_CALLOC (1, sizeof (cli_probe_cmds), cli_mt_cli_cmd);
a3470f
         memcpy (cmd, cli_probe_cmds, sizeof (cli_probe_cmds));
a3470f
         count = (sizeof (cli_probe_cmds) / sizeof (struct cli_cmd));
a3470f
         cli_cmd_sort (cmd, count);
a3470f
 
a3470f
-
a3470f
-
a3470f
         for (probe_cmd = cmd; probe_cmd->pattern; probe_cmd++)
a3470f
                 cli_out ("%s - %s", probe_cmd->pattern, probe_cmd->desc);
a3470f
 
a3470f
         GF_FREE (cmd);
a3470f
+
a3470f
+        cli_out ("\n");
a3470f
         return 0;
a3470f
 }
a3470f
 
a3470f
diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c
a3470f
index e79128c..88b4737 100644
a3470f
--- a/cli/src/cli-cmd-snapshot.c
a3470f
+++ b/cli/src/cli-cmd-snapshot.c
a3470f
@@ -140,9 +140,14 @@ cli_cmd_snapshot_help_cbk (struct cli_state *state,
a3470f
         count = (sizeof (snapshot_cmds) / sizeof (struct cli_cmd));
a3470f
         cli_cmd_sort (cmd, count);
a3470f
 
a3470f
+        cli_out ("\ngluster snapshot commands");
a3470f
+        cli_out ("=========================\n");
a3470f
+
a3470f
         for (snap_cmd = cmd; snap_cmd->pattern; snap_cmd++)
a3470f
                 if (_gf_false == snap_cmd->disable)
a3470f
                         cli_out ("%s - %s", snap_cmd->pattern, snap_cmd->desc);
a3470f
+        cli_out ("\n");
a3470f
+
a3470f
         GF_FREE (cmd);
a3470f
         return 0;
a3470f
 }
a3470f
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
a3470f
index ca9da0a..a1e5c51 100644
a3470f
--- a/cli/src/cli-cmd-volume.c
a3470f
+++ b/cli/src/cli-cmd-volume.c
a3470f
@@ -36,7 +36,19 @@ extern rpc_clnt_prog_t cli_quotad_clnt;
a3470f
 
a3470f
 int
a3470f
 cli_cmd_volume_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
-                      const char **words, int wordcount);
a3470f
+                         const char **words, int wordcount);
a3470f
+
a3470f
+int
a3470f
+cli_cmd_bitrot_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
+                         const char **words, int wordcount);
a3470f
+
a3470f
+int
a3470f
+cli_cmd_quota_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
+                        const char **words, int wordcount);
a3470f
+
a3470f
+int
a3470f
+cli_cmd_tier_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
+                       const char **words, int wordcount);
a3470f
 
a3470f
 int
a3470f
 cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
a3470f
@@ -1293,9 +1305,12 @@ cli_cmd_volume_tier_cbk (struct cli_state *state,
a3470f
 
a3470f
 
a3470f
         if (wordcount < 4) {
a3470f
-                cli_usage_out (word->pattern);
a3470f
-                if (wordcount == 3 && !strcmp(words[2], "help"))
a3470f
+                if (wordcount == 3 && !strcmp(words[2], "help")) {
a3470f
+                        cli_cmd_tier_help_cbk (state, word, words, wordcount);
a3470f
                         ret = 0;
a3470f
+                } else {
a3470f
+                        cli_usage_out (word->pattern);
a3470f
+                }
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
@@ -1719,6 +1734,8 @@ out:
a3470f
         return ret;
a3470f
 }
a3470f
 
a3470f
+
a3470f
+
a3470f
 int
a3470f
 cli_cmd_bitrot_cbk (struct cli_state *state, struct cli_cmd_word *word,
a3470f
                     const char **words, int wordcount)
a3470f
@@ -1746,6 +1763,13 @@ cli_cmd_bitrot_cbk (struct cli_state *state, struct cli_cmd_word *word,
a3470f
                 goto out;
a3470f
         }
a3470f
 
a3470f
+        if (ret == 1) {
a3470f
+                /* this is 'volume bitrot help' */
a3470f
+                cli_cmd_bitrot_help_cbk (state, word, words, wordcount);
a3470f
+                ret = 0;
a3470f
+                goto out2;
a3470f
+        }
a3470f
+
a3470f
         frame = create_frame (THIS, THIS->ctx->pool);
a3470f
         if (!frame) {
a3470f
                 ret = -1;
a3470f
@@ -1834,7 +1858,7 @@ out:
a3470f
 #endif
a3470f
 
a3470f
         CLI_STACK_DESTROY (frame);
a3470f
-
a3470f
+out2:
a3470f
         return ret;
a3470f
 }
a3470f
 
a3470f
@@ -1866,6 +1890,12 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word,
a3470f
                 }
a3470f
         } else {
a3470f
                 ret = cli_cmd_quota_parse (words, wordcount, &options);
a3470f
+
a3470f
+                if (ret == 1) {
a3470f
+                        cli_cmd_quota_help_cbk (state, word, words, wordcount);
a3470f
+                        ret = 0;
a3470f
+                        goto out;
a3470f
+                }
a3470f
                 if (ret < 0) {
a3470f
                         cli_usage_out (word->pattern);
a3470f
                         parse_err = 1;
a3470f
@@ -3157,7 +3187,159 @@ out:
a3470f
         return ret;
a3470f
 }
a3470f
 
a3470f
+
a3470f
+/* This is a bit of a hack to display the help. The current bitrot cmd
a3470f
+ * format does not work well when registering the cmds.
a3470f
+ * Ideally the should have been of the form
a3470f
+ * gluster volume bitrot <subcommand> <volumename> ...
a3470f
+ */
a3470f
+
a3470f
+struct cli_cmd bitrot_cmds[] = {
a3470f
+
a3470f
+        {"volume bitrot help",
a3470f
+         cli_cmd_bitrot_help_cbk,
a3470f
+         "display help for volume bitrot commands"
a3470f
+        },
a3470f
+
a3470f
+        {"volume bitrot <VOLNAME> {enable|disable}",
a3470f
+         NULL, /*cli_cmd_bitrot_cbk,*/
a3470f
+         "Enable/disable bitrot for volume <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        {"volume bitrot <VOLNAME> scrub-throttle {lazy|normal|aggressive}",
a3470f
+         NULL, /*cli_cmd_bitrot_cbk,*/
a3470f
+         "Set the speed of the scrubber for volume <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        {"volume bitrot <VOLNAME> scrub-frequency {hourly|daily|weekly|biweekly"
a3470f
+         "|monthly}",
a3470f
+         NULL, /*cli_cmd_bitrot_cbk,*/
a3470f
+         "Set the frequency of the scrubber for volume <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        {"volume bitrot <VOLNAME> scrub {pause|resume|status|ondemand}",
a3470f
+         NULL, /*cli_cmd_bitrot_cbk,*/
a3470f
+         "Pause/resume the scrubber for <VOLNAME>. Status displays the status of "
a3470f
+         "the scrubber. ondemand starts the scrubber immediately."
a3470f
+        },
a3470f
+
a3470f
+        {"volume bitrot <VOLNAME> {enable|disable}\n"
a3470f
+         "volume bitrot <volname> scrub-throttle {lazy|normal|aggressive}\n"
a3470f
+         "volume bitrot <volname> scrub-frequency {hourly|daily|weekly|biweekly"
a3470f
+         "|monthly}\n"
a3470f
+         "volume bitrot <volname> scrub {pause|resume|status|ondemand}",
a3470f
+         cli_cmd_bitrot_cbk,
a3470f
+         NULL
a3470f
+        },
a3470f
+
a3470f
+        { NULL, NULL, NULL }
a3470f
+};
a3470f
+
a3470f
+
a3470f
+struct cli_cmd quota_cmds[] = {
a3470f
+
a3470f
+        /* Quota commands */
a3470f
+        {"volume quota help",
a3470f
+         cli_cmd_quota_help_cbk,
a3470f
+         "display help for volume quota commands"
a3470f
+        },
a3470f
+
a3470f
+        {"volume quota <VOLNAME> {enable|disable|list [<path> ...]| "
a3470f
+         "list-objects [<path> ...] | remove <path>| remove-objects <path> | "
a3470f
+         "default-soft-limit <percent>}",
a3470f
+         cli_cmd_quota_cbk,
a3470f
+         "Enable/disable and configure quota for <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        {"volume quota <VOLNAME> {limit-usage <path> <size> [<percent>]}",
a3470f
+         cli_cmd_quota_cbk,
a3470f
+         "Set maximum size for <path> for <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        {"volume quota <VOLNAME> {limit-objects <path> <number> [<percent>]}",
a3470f
+         cli_cmd_quota_cbk,
a3470f
+         "Set the maximum number of entries allowed in <path> for <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        {"volume quota <VOLNAME> {alert-time|soft-timeout|hard-timeout} {<time>}",
a3470f
+         cli_cmd_quota_cbk,
a3470f
+         "Set quota timeout for <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        { "volume inode-quota <VOLNAME> enable",
a3470f
+          cli_cmd_quota_cbk,
a3470f
+          "Enable/disable inode-quota for <VOLNAME>"
a3470f
+        },
a3470f
+
a3470f
+        { "volume quota <VOLNAME> {enable|disable|list [<path> ...]| "
a3470f
+          "list-objects [<path> ...] | remove <path>| remove-objects <path> | "
a3470f
+          "default-soft-limit <percent>}\n"
a3470f
+          "volume quota <VOLNAME> {limit-usage <path> <size> [<percent>]}\n"
a3470f
+          "volume quota <VOLNAME> {limit-objects <path> <number> [<percent>]}\n"
a3470f
+          "volume quota <VOLNAME> {alert-time|soft-timeout|hard-timeout} {<time>}",
a3470f
+          cli_cmd_quota_cbk,
a3470f
+          NULL
a3470f
+        },
a3470f
+
a3470f
+        { NULL, NULL, NULL }
a3470f
+};
a3470f
+
a3470f
+struct cli_cmd tier_cmds[] = {
a3470f
+
a3470f
+        { "volume tier help",
a3470f
+          cli_cmd_tier_help_cbk,
a3470f
+          "display help for volume tier commands"},
a3470f
+
a3470f
+        { "volume tier <VOLNAME> status",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          "Display tier status for <VOLNAME>"},
a3470f
+
a3470f
+        { "volume tier <VOLNAME> start [force]",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          "Start the tier service for <VOLNAME>"},
a3470f
+
a3470f
+        { "volume tier <VOLNAME> stop [force]",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          "Stop the tier service for <VOLNAME>"},
a3470f
+
a3470f
+        { "volume tier <VOLNAME> attach [<replica COUNT>] <NEW-BRICK>... [force]",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          "Attach a hot tier to <VOLNAME>"},
a3470f
+
a3470f
+        { "volume tier <VOLNAME> detach <start|stop|status|commit|[force]>",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          "Detach the hot tier from <VOLNAME>"},
a3470f
+
a3470f
+        { "volume attach-tier <VOLNAME> [<replica COUNT>] <NEW-BRICK>...",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          "NOTE: this is old syntax, will be deprecated in next release. "
a3470f
+          "Please use gluster volume tier <vol> attach "
a3470f
+          "[<replica COUNT>] <NEW-BRICK>..."},
a3470f
+
a3470f
+        { "volume detach-tier <VOLNAME> "
a3470f
+          "<start|stop|status|commit|force>",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          "NOTE: this is old syntax, will be deprecated in next release. "
a3470f
+          "Please use gluster volume tier <vol> detach "
a3470f
+          "{start|stop|commit} [force]"},
a3470f
+
a3470f
+        { "volume tier <VOLNAME> status\n"
a3470f
+          "volume tier <VOLNAME> start [force]\n"
a3470f
+          "volume tier <VOLNAME> stop\n"
a3470f
+          "volume tier <VOLNAME> attach [<replica COUNT>] <NEW-BRICK>... [force]\n"
a3470f
+          "volume tier <VOLNAME> detach <start|stop|status|commit|[force]>\n",
a3470f
+          cli_cmd_volume_tier_cbk,
a3470f
+          NULL },
a3470f
+
a3470f
+        {NULL, NULL, NULL}
a3470f
+
a3470f
+        };
a3470f
+
a3470f
 struct cli_cmd volume_cmds[] = {
a3470f
+        { "volume help",
a3470f
+          cli_cmd_volume_help_cbk,
a3470f
+          "display help for volume commands"},
a3470f
+
a3470f
         { "volume info [all|<VOLNAME>]",
a3470f
           cli_cmd_volume_info_cbk,
a3470f
           "list information of all volumes"},
a3470f
@@ -3190,29 +3372,6 @@ struct cli_cmd volume_cmds[] = {
a3470f
           cli_cmd_volume_rename_cbk,
a3470f
           "rename volume <VOLNAME> to <NEW-VOLNAME>"},*/
a3470f
 
a3470f
-#if !defined(__NetBSD__)
a3470f
-        { "volume tier <VOLNAME> status\n"
a3470f
-        "volume tier <VOLNAME> start [force]\n"
a3470f
-        "volume tier <VOLNAME> stop\n"
a3470f
-        "volume tier <VOLNAME> attach [<replica COUNT>] <NEW-BRICK>... [force]\n"
a3470f
-        "volume tier <VOLNAME> detach <start|stop|status|commit|[force]>\n",
a3470f
-        cli_cmd_volume_tier_cbk,
a3470f
-        "Tier translator specific operations."},
a3470f
-
a3470f
-        { "volume attach-tier <VOLNAME> [<replica COUNT>] <NEW-BRICK>...",
a3470f
-        cli_cmd_volume_tier_cbk,
a3470f
-          "NOTE: this is old syntax, will be depreciated in next release. "
a3470f
-          "Please use gluster volume tier <vol> attach "
a3470f
-          "[<replica COUNT>] <NEW-BRICK>..."},
a3470f
-
a3470f
-        { "volume detach-tier <VOLNAME> "
a3470f
-          " <start|stop|status|commit|force>",
a3470f
-        cli_cmd_volume_tier_cbk,
a3470f
-          "NOTE: this is old syntax, will be depreciated in next release. "
a3470f
-          "Please use gluster volume tier <vol> detach "
a3470f
-          "{start|stop|commit} [force]"},
a3470f
-#endif
a3470f
-
a3470f
         { "volume add-brick <VOLNAME> [<stripe|replica> <COUNT> "
a3470f
           "[arbiter <COUNT>]] <NEW-BRICK> ... [force]",
a3470f
           cli_cmd_volume_add_brick_cbk,
a3470f
@@ -3240,9 +3399,6 @@ struct cli_cmd volume_cmds[] = {
a3470f
           cli_cmd_volume_set_cbk,
a3470f
          "set options for volume <VOLNAME>"},
a3470f
 
a3470f
-        { "volume help",
a3470f
-          cli_cmd_volume_help_cbk,
a3470f
-          "display help for the volume command"},
a3470f
 
a3470f
         { "volume log <VOLNAME> rotate [BRICK]",
a3470f
           cli_cmd_log_rotate_cbk,
a3470f
@@ -3273,19 +3429,6 @@ struct cli_cmd volume_cmds[] = {
a3470f
            cli_cmd_volume_profile_cbk,
a3470f
            "volume profile operations"},
a3470f
 
a3470f
-        { "volume quota <VOLNAME> {enable|disable|list [<path> ...]| "
a3470f
-          "list-objects [<path> ...] | remove <path>| remove-objects <path> | "
a3470f
-          "default-soft-limit <percent>} |\n"
a3470f
-          "volume quota <VOLNAME> {limit-usage <path> <size> [<percent>]} |\n"
a3470f
-          "volume quota <VOLNAME> {limit-objects <path> <number> [<percent>]} |\n"
a3470f
-          "volume quota <VOLNAME> {alert-time|soft-timeout|hard-timeout} {<time>}",
a3470f
-          cli_cmd_quota_cbk,
a3470f
-          "quota translator specific operations"},
a3470f
-
a3470f
-        { "volume inode-quota <VOLNAME> enable",
a3470f
-          cli_cmd_quota_cbk,
a3470f
-          "quota translator specific operations"},
a3470f
-
a3470f
          { "volume top <VOLNAME> {open|read|write|opendir|readdir|clear} [nfs|brick <brick>] [list-cnt <value>] |\n"
a3470f
            "volume top <VOLNAME> {read-perf|write-perf} [bs <size> count <count>] [brick <brick>] [list-cnt <value>]",
a3470f
            cli_cmd_volume_top_cbk,
a3470f
@@ -3329,26 +3472,99 @@ struct cli_cmd volume_cmds[] = {
a3470f
          " or all option. gluster volume get all all is to get all global "
a3470f
          "options"
a3470f
         },
a3470f
-        {"volume bitrot <VOLNAME> {enable|disable} |\n"
a3470f
-         "volume bitrot <volname> scrub-throttle {lazy|normal|aggressive} |\n"
a3470f
-         "volume bitrot <volname> scrub-frequency {hourly|daily|weekly|biweekly"
a3470f
-         "|monthly} |\n"
a3470f
-         "volume bitrot <volname> scrub {pause|resume|status|ondemand}",
a3470f
-         cli_cmd_bitrot_cbk,
a3470f
-         "Bitrot translator specific operation. For more information about "
a3470f
-         "bitrot command type  'man gluster'"
a3470f
-        },
a3470f
+
a3470f
         { "volume reset-brick <VOLNAME> <SOURCE-BRICK> {{start} |"
a3470f
           " {<NEW-BRICK> commit}}",
a3470f
           cli_cmd_volume_reset_brick_cbk,
a3470f
           "reset-brick operations"},
a3470f
 
a3470f
+
a3470f
         { NULL, NULL, NULL }
a3470f
 };
a3470f
 
a3470f
 int
a3470f
+cli_cmd_quota_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
+                        const char **words, int wordcount)
a3470f
+{
a3470f
+        struct cli_cmd        *cmd     = NULL;
a3470f
+        struct cli_cmd        *quota_cmd = NULL;
a3470f
+        int                   count    = 0;
a3470f
+
a3470f
+        cmd = GF_CALLOC (1, sizeof (quota_cmds), cli_mt_cli_cmd);
a3470f
+        memcpy (cmd, quota_cmds, sizeof (quota_cmds));
a3470f
+        count = (sizeof (quota_cmds) / sizeof (struct cli_cmd));
a3470f
+        cli_cmd_sort (cmd, count);
a3470f
+
a3470f
+        cli_out ("\ngluster quota commands");
a3470f
+        cli_out ("=======================\n");
a3470f
+
a3470f
+        for (quota_cmd = cmd; quota_cmd->pattern; quota_cmd++)
a3470f
+                if ((_gf_false == quota_cmd->disable) && (quota_cmd->desc))
a3470f
+                        cli_out ("%s - %s", quota_cmd->pattern,
a3470f
+                                 quota_cmd->desc);
a3470f
+
a3470f
+        cli_out ("\n");
a3470f
+        GF_FREE (cmd);
a3470f
+
a3470f
+        return 0;
a3470f
+}
a3470f
+
a3470f
+int
a3470f
+cli_cmd_bitrot_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
+                         const char **words, int wordcount)
a3470f
+{
a3470f
+        struct cli_cmd        *cmd     = NULL;
a3470f
+        struct cli_cmd        *bitrot_cmd = NULL;
a3470f
+        int                   count    = 0;
a3470f
+
a3470f
+        cmd = GF_CALLOC (1, sizeof (bitrot_cmds), cli_mt_cli_cmd);
a3470f
+        memcpy (cmd, bitrot_cmds, sizeof (bitrot_cmds));
a3470f
+        count = (sizeof (bitrot_cmds) / sizeof (struct cli_cmd));
a3470f
+        cli_cmd_sort (cmd, count);
a3470f
+
a3470f
+        cli_out ("\ngluster bitrot commands");
a3470f
+        cli_out ("========================\n");
a3470f
+
a3470f
+        for (bitrot_cmd = cmd; bitrot_cmd->pattern; bitrot_cmd++)
a3470f
+                if ((_gf_false == bitrot_cmd->disable) && (bitrot_cmd->desc))
a3470f
+                        cli_out ("%s - %s", bitrot_cmd->pattern,
a3470f
+                                 bitrot_cmd->desc);
a3470f
+
a3470f
+        cli_out ("\n");
a3470f
+        GF_FREE (cmd);
a3470f
+
a3470f
+        return 0;
a3470f
+}
a3470f
+
a3470f
+int
a3470f
+cli_cmd_tier_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
+                       const char **words, int wordcount)
a3470f
+{
a3470f
+        struct cli_cmd        *cmd     = NULL;
a3470f
+        struct cli_cmd        *tier_cmd = NULL;
a3470f
+        int                   count    = 0;
a3470f
+
a3470f
+        cmd = GF_CALLOC (1, sizeof (tier_cmds), cli_mt_cli_cmd);
a3470f
+        memcpy (cmd, tier_cmds, sizeof (tier_cmds));
a3470f
+        count = (sizeof (tier_cmds) / sizeof (struct cli_cmd));
a3470f
+        cli_cmd_sort (cmd, count);
a3470f
+
a3470f
+        cli_out ("\ngluster tier commands");
a3470f
+        cli_out ("======================\n");
a3470f
+
a3470f
+        for (tier_cmd = cmd; tier_cmd->pattern; tier_cmd++) {
a3470f
+                if ((_gf_false == tier_cmd->disable) && tier_cmd->desc) {
a3470f
+                        cli_out ("%s - %s", tier_cmd->pattern, tier_cmd->desc);
a3470f
+                }
a3470f
+        }
a3470f
+        cli_out ("\n");
a3470f
+        GF_FREE (cmd);
a3470f
+        return 0;
a3470f
+}
a3470f
+
a3470f
+int
a3470f
 cli_cmd_volume_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
-                      const char **words, int wordcount)
a3470f
+                         const char **words, int wordcount)
a3470f
 {
a3470f
         struct cli_cmd        *cmd     = NULL;
a3470f
         struct cli_cmd        *vol_cmd = NULL;
a3470f
@@ -3359,10 +3575,14 @@ cli_cmd_volume_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word,
a3470f
         count = (sizeof (volume_cmds) / sizeof (struct cli_cmd));
a3470f
         cli_cmd_sort (cmd, count);
a3470f
 
a3470f
+        cli_out ("\ngluster volume commands");
a3470f
+        cli_out ("========================\n");
a3470f
+
a3470f
         for (vol_cmd = cmd; vol_cmd->pattern; vol_cmd++)
a3470f
                 if (_gf_false == vol_cmd->disable)
a3470f
                         cli_out ("%s - %s", vol_cmd->pattern, vol_cmd->desc);
a3470f
 
a3470f
+        cli_out ("\n");
a3470f
         GF_FREE (cmd);
a3470f
         return 0;
a3470f
 }
a3470f
@@ -3374,11 +3594,32 @@ cli_cmd_volume_register (struct cli_state *state)
a3470f
         struct cli_cmd *cmd = NULL;
a3470f
 
a3470f
         for (cmd = volume_cmds; cmd->pattern; cmd++) {
a3470f
+                ret = cli_cmd_register (&state->tree, cmd);
a3470f
+                if (ret)
a3470f
+                        goto out;
a3470f
+        }
a3470f
+
a3470f
+        for (cmd = bitrot_cmds; cmd->pattern; cmd++) {
a3470f
+                ret = cli_cmd_register (&state->tree, cmd);
a3470f
+                if (ret)
a3470f
+                        goto out;
a3470f
+        }
a3470f
 
a3470f
+        for (cmd = quota_cmds; cmd->pattern; cmd++) {
a3470f
                 ret = cli_cmd_register (&state->tree, cmd);
a3470f
                 if (ret)
a3470f
                         goto out;
a3470f
         }
a3470f
+
a3470f
+#if !defined(__NetBSD__)
a3470f
+        for (cmd = tier_cmds; cmd->pattern; cmd++) {
a3470f
+                ret = cli_cmd_register (&state->tree, cmd);
a3470f
+                if (ret)
a3470f
+                        goto out;
a3470f
+        }
a3470f
+
a3470f
+#endif
a3470f
+
a3470f
 out:
a3470f
         return ret;
a3470f
 }
a3470f
diff --git a/cli/src/cli.c b/cli/src/cli.c
a3470f
index 18ca5c8..ce06366 100644
a3470f
--- a/cli/src/cli.c
a3470f
+++ b/cli/src/cli.c
a3470f
@@ -515,7 +515,7 @@ cli_usage_out (const char *usage)
a3470f
         if (!usage || usage[0] == '\0')
a3470f
                 return -1;
a3470f
 
a3470f
-        cli_err ("Usage: %s", usage);
a3470f
+        cli_err ("\nUsage:\n%s\n", usage);
a3470f
         return 0;
a3470f
 }
a3470f
 
a3470f
-- 
a3470f
1.8.3.1
a3470f