summaryrefslogtreecommitdiffstats
path: root/cli/src/cli.c
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-10-01 15:06:43 +0200
committerAnand Avati <avati@redhat.com>2012-10-11 18:11:36 -0700
commit68433db9ba07267c72d169b3ed4892e052e2eae2 (patch)
tree48483c7f8bea3586bfae4a5807659f39fe3eab46 /cli/src/cli.c
parentdde806643b736d9c24b4c62ac6826a02929ec4a5 (diff)
cli: introduce "--" as option terminator
This way it becomes possible to pass option-like arguments to cli commands. Change-Id: I8eb1a44ce5d1bfe901d2b3e7cc7bfb84bb3012c9 BUG: 815194 Signed-off-by: Csaba Henk <csaba@redhat.com> Reviewed-on: http://review.gluster.org/4007 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli/src/cli.c')
-rw-r--r--cli/src/cli.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 416cb50bc..7788ce389 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -283,11 +283,20 @@ cli_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
return ret;
}
+
+/*
+ * ret: 0: option successfully processed
+ * 1: signalling end of option list
+ * -1: unknown option or other issue
+ */
int
cli_opt_parse (char *opt, struct cli_state *state)
{
char *oarg;
+ if (strcmp (opt, "") == 0)
+ return 1;
+
if (strcmp (opt, "version") == 0) {
puts (argp_program_version);
exit (0);
@@ -360,6 +369,11 @@ parse_cmdline (int argc, char *argv[], struct cli_state *state)
state->argc--;
/* argv shifted, next check should be at i again */
i--;
+ if (ret == 1) {
+ /* end of cli options */
+ ret = 0;
+ break;
+ }
}
}