Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
tools/vsh.c | 11 +++++++++--
tools/vsh.h | 9 +++++----
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index 8fb033249e..8b58db8896 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -321,7 +321,8 @@ vshCmddefCheckInternals(vshControl *ctl,
char *name = (char *)opt->help; /* cast away const */
char *p;
- if (opt->flags || !opt->help) {
+ if ((opt->flags != 0 && opt->flags != VSH_OFLAG_DEPRECATED) ||
+ !opt->help) {
vshError(ctl, _("parameter '%s' of command '%s' has
incorrect alias option"),
opt->name, cmd->name);
return -1; /* alias options are tracked by the original name */
@@ -442,6 +443,11 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char
*name,
const vshCmdOptDef *opt = &cmd->opts[i];
if (STREQ(opt->name, name)) {
+ if (report && (opt->flags & VSH_OFLAG_DEPRECATED)) {
+ vshDebug(ctl, VSH_ERR_WARNING,
+ _("Warning: Option '%s' is deprecated\n"),
name);
+ }
+
if (opt->type == VSH_OT_ALIAS) {
char *value;
@@ -697,7 +703,8 @@ vshCmddefHelp(const vshCmdDef *def)
continue;
}
- fprintf(stdout, " %-15s %s\n", buf, _(opt->help));
+ fprintf(stdout, " %-15s %s%s\n", buf, _(opt->help),
+ opt->flags & VSH_OFLAG_DEPRECATED ? " (deprecated)"
: "");
}
}
fputc('\n', stdout);
diff --git a/tools/vsh.h b/tools/vsh.h
index e83e0eca9e..e85206b726 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -98,10 +98,11 @@ typedef enum {
* Command Option Flags
*/
enum {
- VSH_OFLAG_NONE = 0, /* without flags */
- VSH_OFLAG_REQ = (1 << 0), /* option required */
- VSH_OFLAG_EMPTY_OK = (1 << 1), /* empty string option allowed */
- VSH_OFLAG_REQ_OPT = (1 << 2), /* --optionname required */
+ VSH_OFLAG_NONE = 0, /* without flags */
+ VSH_OFLAG_REQ = (1 << 0), /* option required */
+ VSH_OFLAG_EMPTY_OK = (1 << 1), /* empty string option allowed */
+ VSH_OFLAG_REQ_OPT = (1 << 2), /* --optionname required */
+ VSH_OFLAG_DEPRECATED = (1 << 3), /* option is deprecated */
};
/* forward declarations */
--
2.26.2