- move the check that completer_flags are 0 if no completer is set into a common place and remove duplication - add check that _BOOL arguments are not positional - add missing checks to _ALIAS Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- tools/vsh.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index e6ea3a398a..a4235905dc 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -332,6 +332,13 @@ vshCmddefCheckInternals(vshControl *ctl, return -1; } + /* Mandate no completer flags if no completer is specified */ + if (opt->completer_flags != 0 && !opt->completer) { + vshError(ctl, "completer_flags of argument '%s' of command '%s' must be 0 if no completer is used", + opt->name, cmd->name); + return -1; + } + switch (opt->type) { case VSH_OT_NONE: vshError(ctl, "invalid type 'NONE' of option '%s' of command '%s'", @@ -339,12 +346,18 @@ vshCmddefCheckInternals(vshControl *ctl, return -1; case VSH_OT_BOOL: - if (opt->completer || opt->completer_flags) { + if (opt->completer) { vshError(ctl, "bool parameter '%s' of command '%s' has completer set", opt->name, cmd->name); return -1; } + if (opt->positional) { + vshError(ctl, "boolean parameter '%s' of command '%s' must not be positional", + opt->name, cmd->name); + return -1; + } + if (opt->required) { vshError(ctl, "parameter '%s' of command '%s' misused 'required' flag", opt->name, cmd->name); @@ -358,7 +371,11 @@ vshCmddefCheckInternals(vshControl *ctl, g_autofree char *name = NULL; char *p; - if (opt->flags || !opt->help) { + if (opt->required || + opt->positional || + opt->completer || + opt->flags || + !opt->help) { vshError(ctl, "parameter '%s' of command '%s' has incorrect alias option", opt->name, cmd->name); return -1; -- 2.44.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx