Replace the last bitwise flag with a separate member.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE),
{.name = "device",
.type = VSH_OT_STRING,
- .flags = VSH_OFLAG_EMPTY_OK,
.positional = true,
+ .allowEmpty = true,
.completer = virshDomainDiskTargetCompleter,
.help = N_("block device")
},
.type = VSH_OT_STRING,
.positional = true,
.required = true,
- .flags = VSH_OFLAG_EMPTY_OK,
+ .allowEmpty = true,
.help = N_("source of disk device or name of network disk")
},
{.name = "target",
{.name = "cpulist",
.type = VSH_OT_STRING,
.unwanted_positional = true,
- .flags = VSH_OFLAG_EMPTY_OK,
+ .allowEmpty = true,
.completer = virshDomainCpulistCompleter,
.help = N_("host cpu number(s) to set, or omit option to query")
},
{.name = "cpulist",
.type = VSH_OT_STRING,
.unwanted_positional = true,
- .flags = VSH_OFLAG_EMPTY_OK,
+ .allowEmpty = true,
.completer = virshDomainCpulistCompleter,
.help = N_("host cpu number(s) to set, or omit option to query")
},
{.name = "name",
.type = VSH_OT_STRING,
.positional = true,
- .flags = VSH_OFLAG_EMPTY_OK,
+ .allowEmpty = true,
.completer = virshCompleteEmpty,
.help = N_("hypervisor connection URI")
},
{.name = "name",
.type = VSH_OT_STRING,
.positional = true,
- .flags = VSH_OFLAG_EMPTY_OK,
+ .allowEmpty = true,
.help = N_("daemon's admin server connection URI")
},
{.name = NULL}
.type = VSH_OT_STRING,
.positional = true,
.help = N_("redefine the existing set of logging filters"),
- .flags = VSH_OFLAG_EMPTY_OK
+ .allowEmpty = true
},
{.name = NULL}
};
.type = VSH_OT_STRING,
.positional = true,
.help = N_("redefine the existing set of logging outputs"),
- .flags = VSH_OFLAG_EMPTY_OK
+ .allowEmpty = true
},
{.name = NULL}
};
if ((ret = vshCommandOpt(cmd, name, &arg, true)) <= 0)
return ret;
- if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
+ if (!arg->def->allowEmpty && *arg->data == '\0')
return -1;
*value = arg->data;
return 1;
/* this should not be propagated here, just to be sure */
if (ret == -1)
error = N_("Mandatory option not present");
- else if (arg && !*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK))
+ else if (arg && *arg->data == '\0' && !arg->def->allowEmpty)
error = N_("Option argument is empty");
if (error) {
{.name = "string",
.type = VSH_OT_ARGV,
.positional = true,
- .flags = VSH_OFLAG_EMPTY_OK,
+ .allowEmpty = true,
.help = N_("partial string to autocomplete")
},
{.name = NULL}
*/
enum {
VSH_OFLAG_NONE = 0, /* without flags */
- VSH_OFLAG_EMPTY_OK = (1 << 1), /* empty string option allowed */
};
/* forward declarations */
bool unwanted_positional;
unsigned int flags; /* flags */
+ bool allowEmpty; /* allow empty string */
const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
* the name of a later public option */
vshCompleter completer; /* option completer */