blobcli: fix incorrect error message

If a config file is specified an error message would incorrectly
print.

Change-Id: I532762f6e6ed26bd213255b0e67663035fc1620e
Signed-off-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/382876
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Paul Luse 2017-10-17 13:42:00 -07:00 committed by Jim Harris
parent e5044f7930
commit cbe9216ee4

View File

@ -958,12 +958,14 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
int op; int op;
int cmd_chosen = 0; int cmd_chosen = 0;
char resp; char resp;
bool cfg_specified = false;
while ((op = getopt(argc, argv, "c:d:f:hil:m:n:p:r:s:ST:Xx:")) != -1) { while ((op = getopt(argc, argv, "c:d:f:hil:m:n:p:r:s:ST:Xx:")) != -1) {
switch (op) { switch (op) {
case 'c': case 'c':
if (cli_context->app_started == false) { if (cli_context->app_started == false) {
cmd_chosen++; cmd_chosen++;
cfg_specified = true;
cli_context->config_file = optarg; cli_context->config_file = optarg;
} else { } else {
usage(cli_context, "ERROR: -c option not valid during shell mode.\n"); usage(cli_context, "ERROR: -c option not valid during shell mode.\n");
@ -1086,10 +1088,8 @@ cmd_parser(int argc, char **argv, struct cli_context_t *cli_context)
usage(cli_context, "ERROR: invalid option\n"); usage(cli_context, "ERROR: invalid option\n");
} }
/* config file is the only option that can be combined */ /* config file is the only option that can be combined */
if (op != 'c') { if (cfg_specified == false && cmd_chosen > 1) {
if (cmd_chosen > 1) { usage(cli_context, "Error: Please choose only one command\n");
usage(cli_context, "Error: Please choose only one command\n");
}
} }
} }