diff --git a/cmd/completion/completion.go b/cmd/completion/completion.go index bff609942..eaab16acb 100644 --- a/cmd/completion/completion.go +++ b/cmd/completion/completion.go @@ -36,6 +36,7 @@ func NewCompletionCommand() *cobra.Command { Use: "completion SHELL", Short: "Generate autocompletions script for the specified shell (bash or zsh)", Long: completionDesc, + Args: cobra.ExactArgs(1), RunE: runCompletion, ValidArgs: shells, } @@ -44,12 +45,6 @@ func NewCompletionCommand() *cobra.Command { } func runCompletion(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return fmt.Errorf("shell not specified") - } - if len(args) > 1 { - return fmt.Errorf("too many arguments, expected only the shell type") - } run, found := completionShells[args[0]] if !found { return fmt.Errorf("unsupported shell type %q", args[0]) diff --git a/cmd/completion/completion_test.go b/cmd/completion/completion_test.go index 7b56d05c5..0e4791384 100644 --- a/cmd/completion/completion_test.go +++ b/cmd/completion/completion_test.go @@ -22,18 +22,6 @@ func TestCompletion(t *testing.T) { CmdLine: "zsh", Cmd: cmd, }, - { - Name: "completion-no-args", - CmdLine: "", - Cmd: cmd, - Error: errors.New("shell not specified"), - }, - { - Name: "completion-too-many-args", - CmdLine: "bash zsh", - Cmd: cmd, - Error: errors.New("too many arguments, expected only the shell type"), - }, { Name: "completion-unknown-shell", CmdLine: "fish",