Introduce a proper flag 'VSH_CMD_FLAG_HIDDEN' for hiding commands from
output so that we can validate that there aren't any loops or
misconfigured commands.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tools/virsh.c | 3 ++-
tools/virt-admin.c | 3 ++-
tools/vsh.c | 9 ++++++---
tools/vsh.h | 7 +++----
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index ce5fd247dd..3c6f60f176 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -464,7 +464,8 @@ virshUsage(void)
fprintf(stdout, _(" %s (help keyword '%s')\n"),
grp->name, grp->keyword);
for (cmd = grp->commands; cmd->name; cmd++) {
- if (cmd->flags & VSH_CMD_FLAG_ALIAS)
+ if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
+ cmd->flags & VSH_CMD_FLAG_HIDDEN)
continue;
fprintf(stdout,
" %-30s %s\n", cmd->name,
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index c8e7ee794a..c0818e850a 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -1235,7 +1235,8 @@ vshAdmUsage(void)
fprintf(stdout, _(" %s (help keyword '%s')\n"),
grp->name, grp->keyword);
for (cmd = grp->commands; cmd->name; cmd++) {
- if (cmd->flags & VSH_CMD_FLAG_ALIAS)
+ if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
+ cmd->flags & VSH_CMD_FLAG_HIDDEN)
continue;
fprintf(stdout,
" %-30s %s\n", cmd->name,
diff --git a/tools/vsh.c b/tools/vsh.c
index ea078c707b..eb17a58dc0 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -577,7 +577,8 @@ vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp)
grp->keyword);
for (cmd = grp->commands; cmd->name; cmd++) {
- if (cmd->flags & VSH_CMD_FLAG_ALIAS)
+ if (cmd->flags & VSH_CMD_FLAG_ALIAS ||
+ cmd->flags & VSH_CMD_FLAG_HIDDEN)
continue;
vshPrint(ctl, " %-30s %s\n", cmd->name,
_(vshCmddefGetInfo(cmd, "help")));
@@ -2544,7 +2545,8 @@ 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].flags & VSH_CMD_FLAG_ALIAS ||
+ cmds[cmd_list_index].flags & VSH_CMD_FLAG_HIDDEN)
continue;
VIR_REALLOC_N(ret, ret_size + 2);
@@ -3029,7 +3031,8 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
grp->keyword);
for (def = grp->commands; def->name; def++) {
- if (def->flags & VSH_CMD_FLAG_ALIAS)
+ if (def->flags & VSH_CMD_FLAG_ALIAS ||
+ def->flags & VSH_CMD_FLAG_HIDDEN)
continue;
vshPrint(ctl, " %-30s %s\n", def->name,
_(vshCmddefGetInfo(def, "help")));
diff --git a/tools/vsh.h b/tools/vsh.h
index 39f70913fe..ae50f6b220 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -163,6 +163,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 */
};
/*
@@ -446,8 +447,7 @@ bool cmdComplete(vshControl *ctl, const vshCmd *cmd);
.handler = cmdSelfTest, \
.opts = NULL, \
.info = info_selftest, \
- .flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS, \
- .alias = "self-test" \
+ .flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_HIDDEN, \
}
#define VSH_CMD_COMPLETE \
@@ -456,8 +456,7 @@ bool cmdComplete(vshControl *ctl, const vshCmd *cmd);
.handler = cmdComplete, \
.opts = opts_complete, \
.info = info_complete, \
- .flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_ALIAS, \
- .alias = "complete" \
+ .flags = VSH_CMD_FLAG_NOCONNECT | VSH_CMD_FLAG_HIDDEN, \
}
--
2.31.1