diff --git a/pkg/commands/completion.go b/pkg/commands/completion.go deleted file mode 100644 index e2be6f292929..000000000000 --- a/pkg/commands/completion.go +++ /dev/null @@ -1,85 +0,0 @@ -package commands - -import ( - "fmt" - "os" - - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -func (e *Executor) initCompletion() { - completionCmd := &cobra.Command{ - Use: "completion", - Short: "Output completion script", - } - e.rootCmd.AddCommand(completionCmd) - - bashCmd := &cobra.Command{ - Use: "bash", - Short: "Output bash completion script", - RunE: e.executeBashCompletion, - } - completionCmd.AddCommand(bashCmd) - - zshCmd := &cobra.Command{ - Use: "zsh", - Short: "Output zsh completion script", - RunE: e.executeZshCompletion, - } - completionCmd.AddCommand(zshCmd) - - fishCmd := &cobra.Command{ - Use: "fish", - Short: "Output fish completion script", - RunE: e.executeFishCompletion, - } - completionCmd.AddCommand(fishCmd) - - powerShell := &cobra.Command{ - Use: "powershell", - Short: "Output powershell completion script", - RunE: e.executePowerShellCompletion, - } - completionCmd.AddCommand(powerShell) -} - -func (e *Executor) executeBashCompletion(cmd *cobra.Command, args []string) error { - err := cmd.Root().GenBashCompletion(os.Stdout) - if err != nil { - return errors.Wrap(err, "unable to generate bash completions: %v") - } - - return nil -} - -func (e *Executor) executeZshCompletion(cmd *cobra.Command, args []string) error { - err := cmd.Root().GenZshCompletion(os.Stdout) - if err != nil { - return errors.Wrap(err, "unable to generate zsh completions: %v") - } - // Add extra compdef directive to support sourcing command directly. - // https://github.com/spf13/cobra/issues/881 - // https://github.com/spf13/cobra/pull/887 - fmt.Println("compdef _golangci-lint golangci-lint") - - return nil -} - -func (e *Executor) executeFishCompletion(cmd *cobra.Command, args []string) error { - err := cmd.Root().GenFishCompletion(os.Stdout, true) - if err != nil { - return errors.Wrap(err, "generate fish completion") - } - - return nil -} - -func (e *Executor) executePowerShellCompletion(cmd *cobra.Command, args []string) error { - err := cmd.Root().GenPowerShellCompletion(os.Stdout) - if err != nil { - return errors.Wrap(err, "generate powershell completion") - } - - return nil -} diff --git a/pkg/commands/executor.go b/pkg/commands/executor.go index a060709ef713..3edb6e4b0e3b 100644 --- a/pkg/commands/executor.go +++ b/pkg/commands/executor.go @@ -97,7 +97,6 @@ func NewExecutor(version, commit, date string) *Executor { e.initHelp() e.initLinters() e.initConfig() - e.initCompletion() e.initVersion() e.initCache()