fix: do not print out help string if the parameters are correct

There was an issue that `talosctl apply config` version was printing out
the help even if arguments are correct.

Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
This commit is contained in:
Artem Chernyshev 2021-03-09 20:58:51 +03:00 committed by talos-bot
parent 56c95eace3
commit c2e353d6af

View File

@ -42,11 +42,13 @@ var applyConfigCmd = &cobra.Command{
)
if len(args) > 0 {
cmd.Help() //nolint:errcheck
if args[0] != "config" && !strings.EqualFold(args[0], "machineconfig") {
cmd.Help() //nolint:errcheck
return fmt.Errorf("unknown positional argument %s", args[0])
} else if cmd.CalledAs() == "apply-config" {
cmd.Help() //nolint:errcheck
return fmt.Errorf("expected no positional arguments")
}
}