VSH_OT_STRING, /* optional string option */
VSH_OT_INT, /* optional or mandatory int option */
VSH_OT_DATA, /* string data (as non-option) */
- VSH_OT_ARGV /* remaining arguments, opt->name should be "" */
+ VSH_OT_ARGV /* remaining arguments */
} vshCmdOptType;
/*
static const vshCmdOptDef opts_echo[] = {
{"shell", VSH_OT_BOOL, 0, N_("escape for shell use")},
{"xml", VSH_OT_BOOL, 0, N_("escape for XML use")},
- {"", VSH_OT_ARGV, 0, N_("arguments to echo")},
+ {"string", VSH_OT_ARGV, 0, N_("arguments to echo")},
{NULL, 0, 0, NULL}
};
vshError(ctl, _("option --%s already seen"), name);
return NULL;
}
+ if (opt->type == VSH_OT_ARGV) {
+ vshError(ctl, _("variable argument <%s> "
+ "should not be used with --<%s>"), name, name);
+ return NULL;
+ }
*opts_seen |= 1 << i;
return opt;
}
const vshCmdOptDef *opt = &def->opts[i];
vshError(ctl,
- opt->type == VSH_OT_DATA ?
+ opt->type == VSH_OT_DATA || opt->type == VSH_OT_ARGV ?
_("command '%s' requires <%s> option") :
_("command '%s' requires --%s option"),
def->name, opt->name);
break;
case VSH_OT_ARGV:
/* xgettext:c-format */
- fmt = _("[<string>]...");
+ fmt = (opt->flag & VSH_OFLAG_REQ) ? _("<%s>...")
+ : _("[<%s>]...");
break;
default:
assert(0);
break;
case VSH_OT_ARGV:
/* Not really an option. */
- continue;
+ snprintf(buf, sizeof(buf), _("<%s>"), opt->name);
+ break;
default:
assert(0);
}
list_index++;
- if (opt->type == VSH_OT_DATA)
+ if (opt->type == VSH_OT_DATA || opt->type == VSH_OT_ARGV)
/* ignore non --option */
continue;