summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd.c
diff options
context:
space:
mode:
authorMohamed Ashiq <mliyazud@redhat.com>2015-07-15 14:19:49 +0530
committerNiels de Vos <ndevos@redhat.com>2015-11-02 02:03:28 -0800
commit0b6f0e09715fb2ba8f86bd80b05d552ae75aeda9 (patch)
tree6186add585892688da794b475de3c11b218d32bd /cli/src/cli-cmd.c
parent43d819bc99874ee900a03a27c79cd8523423d9b6 (diff)
cli : 'gluster volume help' output sorted alphabetically
'gluster volume help' output is not sorted alphabetically. This makes little harder for the user to search or get to know of few gluster volume commands usage just from gluster cli. Backport of http://review.gluster.org/11663 Cherry picked from 323e71617fee5020324540776d0d4469577f0afe Change-Id: I855da2e4748a5c2ff3be319c50fa9548d676ee8a BUG: 1276208 Signed-off-by: Mohamed Ashiq <mliyazud@redhat.com> >Reviewed-on: http://review.gluster.org/11663 >Tested-by: Gluster Build System <jenkins@build.gluster.com> >Reviewed-by: Manikandan Selvaganesh <mselvaga@redhat.com> >Reviewed-by: Anand Nekkunti <anekkunt@redhat.com> Reviewed-on: http://review.gluster.org/12452 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Nekkunti <anekkunt@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd.c')
-rw-r--r--cli/src/cli-cmd.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c
index 5ea1edc9cac..12629b7b5f1 100644
--- a/cli/src/cli-cmd.c
+++ b/cli/src/cli-cmd.c
@@ -395,3 +395,28 @@ cli_cmd_submit (struct rpc_clnt* rpc, void *req, call_frame_t *frame,
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
+
+int
+cli_cmd_pattern_cmp (void *a, void *b)
+{
+ struct cli_cmd *ia = NULL;
+ struct cli_cmd *ib = NULL;
+ int ret = 0;
+
+ ia = a;
+ ib = b;
+ if (strcmp (ia->pattern, ib->pattern) > 0)
+ ret = 1;
+ else if (strcmp (ia->pattern, ib->pattern) < 0)
+ ret = -1;
+ else
+ ret = 0;
+ return ret;
+}
+
+void
+cli_cmd_sort (struct cli_cmd *cmd, int count)
+{
+ gf_array_insertionsort (cmd, 1, count - 2, sizeof(struct cli_cmd),
+ cli_cmd_pattern_cmp);
+}