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>
This commit is contained in:
parent
dde806643b
commit
68433db9ba
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user