case VSH_OT_ARGV:
if (brokenPositionals == 0 ||
brokenPositionals == opt->type) {
- if (!(opt->flags & VSH_OFLAG_REQ_OPT) && !opt->positional)
+ if (!(opt->flags & VSH_OFLAG_REQ_OPT) &&
+ !(opt->positional || opt->unwanted_positional))
virBufferStrcat(&posbuf, opt->name, ", ", NULL);
}
break;
return -1;
}
+ if (opt->unwanted_positional && opt->positional) {
+ vshError(ctl, "unwanted_positional flag of argument '%s' of command '%s' must not be used together with positional",
+ opt->name, cmd->name);
+ return -1;
+ }
+
switch (opt->type) {
case VSH_OT_NONE:
vshError(ctl, "invalid type 'NONE' of option '%s' of command '%s'",
return -1;
}
- if (opt->positional) {
+ if (opt->positional || opt->unwanted_positional) {
vshError(ctl, "boolean parameter '%s' of command '%s' must not be positional",
opt->name, cmd->name);
return -1;
if (opt->required ||
opt->positional ||
+ opt->unwanted_positional ||
opt->completer ||
opt->flags ||
!opt->help) {
vshCmdOptType type; /* option type */
bool required; /* option is required */
bool positional; /* option is a positional option (not requiring '--optionname') */
+
+ /* Historically the command parser in virsh allowed many optional arguments
+ * which were documented as non-positional to be filled positionally. To
+ * preserve this functionality those need to be annotated with the
+ * 'unwanted_positional' flag. New options must not use this flag */
+ bool unwanted_positional;
+
unsigned int flags; /* flags */
const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
* the name of a later public option */