golangci-lint/pkg/commands/completion.go
2019-09-10 11:30:02 +03:00

27 lines
515 B
Go

package commands
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
func (e *Executor) initCompletion() {
completionCmd := &cobra.Command{
Use: "completion",
Short: "Generates bash completion scripts",
RunE: e.executeCompletion,
}
e.rootCmd.AddCommand(completionCmd)
}
func (e *Executor) executeCompletion(cmd *cobra.Command, args []string) error {
err := cmd.Root().GenBashCompletion(os.Stdout)
if err != nil {
return fmt.Errorf("unable to generate bash completions: %v", err)
}
return nil
}