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(a)redhat.com>
---
tools/virsh-nodedev.c | 1 -
tools/virsh.c | 2 +-
tools/virt-admin.c | 9 +--------
tools/vsh.c | 21 ++++++++-------------
tools/vsh.h | 3 +--
5 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index c08de65a96..b5a88b194f 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -1415,7 +1415,6 @@ const vshCmdDef nodedevCmds[] = {
.flags = 0
},
{.name = "nodedev-dettach",
- .flags = VSH_CMD_FLAG_ALIAS,
.alias = "nodedev-detach"
},
{.name = "nodedev-dumpxml",
diff --git a/tools/virsh.c b/tools/virsh.c
index 18cd279aba..0d860d0390 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -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,
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index f551b33c4b..27bd123bfe 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -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",
diff --git a/tools/vsh.c b/tools/vsh.c
index a3491695b9..08a08bb227 100644
--- a/tools/vsh.c
+++ b/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);
cmd = vshCmddefSearch(tkdata);
@@ -2594,7 +2589,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;
@@ -3095,7 +3090,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,
@@ -3109,7 +3104,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);
return vshCmddefHelp(def);
} else if ((grp = vshCmdGrpSearch(name))) {
diff --git a/tools/vsh.h b/tools/vsh.h
index 2cc0a62d3f..a191b50c2d 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -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 */
};
/*
--
2.44.0