mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
vsh: Remove VSH_CMD_FLAG_ALIAS
It's obvious that a command is an alias when the 'alias' property is set, thus an extra flag is redundant. Remove it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3fcae7a028
commit
7abb44f5f7
@ -1415,7 +1415,6 @@ const vshCmdDef nodedevCmds[] = {
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "nodedev-dettach",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "nodedev-detach"
|
||||
},
|
||||
{.name = "nodedev-dumpxml",
|
||||
|
@ -460,7 +460,7 @@ virshUsage(void)
|
||||
fprintf(stdout, _(" %1$s (help keyword '%2$s')\n"),
|
||||
grp->name, grp->keyword);
|
||||
for (cmd = grp->commands; cmd->name; cmd++) {
|
||||
if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
|
||||
if (cmd->alias ||
|
||||
cmd->flags & VSH_CMD_FLAG_HIDDEN)
|
||||
continue;
|
||||
fprintf(stdout,
|
||||
|
@ -1262,7 +1262,7 @@ vshAdmUsage(void)
|
||||
fprintf(stdout, _(" %1$s (help keyword '%2$s')\n"),
|
||||
grp->name, grp->keyword);
|
||||
for (cmd = grp->commands; cmd->name; cmd++) {
|
||||
if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
|
||||
if (cmd->alias ||
|
||||
cmd->flags & VSH_CMD_FLAG_HIDDEN)
|
||||
continue;
|
||||
fprintf(stdout,
|
||||
@ -1429,7 +1429,6 @@ static const vshCmdDef vshAdmCmds[] = {
|
||||
|
||||
static const vshCmdDef monitoringCmds[] = {
|
||||
{.name = "srv-list",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "server-list"
|
||||
},
|
||||
{.name = "server-list",
|
||||
@ -1439,7 +1438,6 @@ static const vshCmdDef monitoringCmds[] = {
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "srv-threadpool-info",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "server-threadpool-info"
|
||||
},
|
||||
{.name = "server-threadpool-info",
|
||||
@ -1449,7 +1447,6 @@ static const vshCmdDef monitoringCmds[] = {
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "srv-clients-list",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "client-list"
|
||||
},
|
||||
{.name = "client-list",
|
||||
@ -1465,7 +1462,6 @@ static const vshCmdDef monitoringCmds[] = {
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "srv-clients-info",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "server-clients-info"
|
||||
},
|
||||
{.name = "server-clients-info",
|
||||
@ -1479,7 +1475,6 @@ static const vshCmdDef monitoringCmds[] = {
|
||||
|
||||
static const vshCmdDef managementCmds[] = {
|
||||
{.name = "srv-threadpool-set",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "server-threadpool-set"
|
||||
},
|
||||
{.name = "server-threadpool-set",
|
||||
@ -1495,7 +1490,6 @@ static const vshCmdDef managementCmds[] = {
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "srv-clients-set",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "server-clients-set"
|
||||
},
|
||||
{.name = "server-clients-set",
|
||||
@ -1505,7 +1499,6 @@ static const vshCmdDef managementCmds[] = {
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "srv-update-tls",
|
||||
.flags = VSH_CMD_FLAG_ALIAS,
|
||||
.alias = "server-update-tls"
|
||||
},
|
||||
{.name = "server-update-tls",
|
||||
|
21
tools/vsh.c
21
tools/vsh.c
@ -268,21 +268,16 @@ vshCmddefCheckInternals(vshControl *ctl,
|
||||
g_auto(virBuffer) complbuf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
/* in order to perform the validation resolve the alias first */
|
||||
if (cmd->flags & VSH_CMD_FLAG_ALIAS) {
|
||||
if (cmd->alias) {
|
||||
const vshCmdDef *alias;
|
||||
|
||||
if (!cmd->alias) {
|
||||
vshError(ctl, "command '%s' has inconsistent alias", cmd->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(alias = vshCmddefSearch(cmd->alias))) {
|
||||
vshError(ctl, "command alias '%s' is pointing to a non-existent command '%s'",
|
||||
cmd->name, cmd->alias);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (alias->flags & VSH_CMD_FLAG_ALIAS) {
|
||||
if (alias->alias) {
|
||||
vshError(ctl, "command alias '%s' is pointing to another command alias '%s'",
|
||||
cmd->name, cmd->alias);
|
||||
return -1;
|
||||
@ -303,7 +298,7 @@ vshCmddefCheckInternals(vshControl *ctl,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cmd->flags & ~VSH_CMD_FLAG_ALIAS) {
|
||||
if (cmd->flags != 0) {
|
||||
vshError(ctl, "command '%s' has multiple flags set", cmd->name);
|
||||
return -1;
|
||||
}
|
||||
@ -615,7 +610,7 @@ vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp)
|
||||
grp->keyword);
|
||||
|
||||
for (cmd = grp->commands; cmd->name; cmd++) {
|
||||
if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
|
||||
if (cmd->alias ||
|
||||
cmd->flags & VSH_CMD_FLAG_HIDDEN)
|
||||
continue;
|
||||
vshPrint(ctl, " %-30s %s\n", cmd->name,
|
||||
@ -1407,7 +1402,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
|
||||
}
|
||||
|
||||
/* aliases need to be resolved to the actual commands */
|
||||
if (cmd->flags & VSH_CMD_FLAG_ALIAS) {
|
||||
if (cmd->alias) {
|
||||
VIR_FREE(tkdata);
|
||||
tkdata = g_strdup(cmd->alias);
|
||||
if (!(cmd = vshCmddefSearch(tkdata))) {
|
||||
@ -2630,7 +2625,7 @@ vshReadlineCommandGenerator(void)
|
||||
for (cmd_list_index = 0; cmds[cmd_list_index].name; cmd_list_index++) {
|
||||
const char *name = cmds[cmd_list_index].name;
|
||||
|
||||
if (cmds[cmd_list_index].flags & VSH_CMD_FLAG_ALIAS ||
|
||||
if (cmds[cmd_list_index].alias ||
|
||||
cmds[cmd_list_index].flags & VSH_CMD_FLAG_HIDDEN)
|
||||
continue;
|
||||
|
||||
@ -3131,7 +3126,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
|
||||
grp->keyword);
|
||||
|
||||
for (def = grp->commands; def->name; def++) {
|
||||
if (def->flags & VSH_CMD_FLAG_ALIAS ||
|
||||
if (def->alias ||
|
||||
def->flags & VSH_CMD_FLAG_HIDDEN)
|
||||
continue;
|
||||
vshPrint(ctl, " %-30s %s\n", def->name,
|
||||
@ -3145,7 +3140,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
if ((def = vshCmddefSearch(name))) {
|
||||
if (def->flags & VSH_CMD_FLAG_ALIAS)
|
||||
if (def->alias)
|
||||
def = vshCmddefSearch(def->alias);
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,7 @@ struct _vshCmdOpt {
|
||||
*/
|
||||
enum {
|
||||
VSH_CMD_FLAG_NOCONNECT = (1 << 0), /* no prior connection needed */
|
||||
VSH_CMD_FLAG_ALIAS = (1 << 1), /* command is an alias */
|
||||
VSH_CMD_FLAG_HIDDEN = (1 << 2), /* command is hidden/internal */
|
||||
VSH_CMD_FLAG_HIDDEN = (1 << 1), /* command is hidden/internal */
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user