.flags = 0
},
{.name = "nodedev-dettach",
- .handler = cmdNodeDeviceDetach,
- .opts = opts_node_device_detach,
- .info = info_node_device_detach,
- .flags = VSH_CMD_FLAG_ALIAS
+ .flags = VSH_CMD_FLAG_ALIAS,
+ .alias = "nodedev-detach"
},
{.name = "nodedev-dumpxml",
.handler = cmdNodeDeviceDumpXML,
size_t i;
const char *help = NULL;
+ /* in order to perform the validation resolve the alias first */
+ if (cmd->flags & VSH_CMD_FLAG_ALIAS) {
+ if (!cmd->alias)
+ return -1;
+ cmd = vshCmddefSearch(cmd->alias);
+ }
+
/* Each command has to provide a non-empty help string. */
if (!(help = vshCmddefGetInfo(cmd, "help")) || !*help)
return -1;
vshError(ctl, _("unknown command: '%s'"), tkdata);
goto syntaxError; /* ... or ignore this command only? */
}
+
+ /* aliases need to be resolved to the actual commands */
+ if (cmd->flags & VSH_CMD_FLAG_ALIAS) {
+ VIR_FREE(tkdata);
+ tkdata = vshStrdup(ctl, cmd->alias);
+ cmd = vshCmddefSearch(tkdata);
+ }
if (vshCmddefOptParse(cmd, &opts_need_arg,
&opts_required) < 0) {
vshError(ctl,
if (cmds[cmd_list_index].name) {
while ((name = cmds[cmd_list_index].name)) {
- cmd_list_index++;
+ if (cmds[cmd_list_index++].flags & VSH_CMD_FLAG_ALIAS)
+ continue;
if (STREQLEN(name, text, len))
return vshStrdup(NULL, name);
if (!cmd) {
if (!(cmd = vshCmddefSearch(tkdata)))
goto error;
- cmd_exists = true;
+ if (cmd->flags & VSH_CMD_FLAG_ALIAS)
+ cmd = vshCmddefSearch(cmd->alias);
+ cmd_exists = true;
if (vshCmddefOptParse(cmd, &const_opts_need_arg,
&const_opts_required) < 0)
goto error;
for (grp = cmdGroups; grp->name; grp++) {
for (def = grp->commands; def->name; def++) {
- if (def->flags & VSH_CMD_FLAG_ALIAS)
- continue;
-
if (vshCmddefCheckInternals(def) < 0)
return false;
}
const vshCmdOptDef *opts; /* definition of command options */
const vshCmdInfo *info; /* details about command */
unsigned int flags; /* bitwise OR of VSH_CMD_FLAG */
+ const char *alias; /* name of the aliased command */
};
/*
.handler = cmdSelfTest, \
.opts = NULL, \
.info = info_selftest, \
- .flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS \
+ .flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS, \
+ .alias = "self-test" \
}