diff --git a/pkg/commands/executor.go b/pkg/commands/executor.go index 42b179db..62429e72 100644 --- a/pkg/commands/executor.go +++ b/pkg/commands/executor.go @@ -82,6 +82,7 @@ func NewExecutor(version, commit, date string) *Executor { e.initLinters() e.initConfig() e.initCompletion() + e.initVersion() // init e.cfg by values from config: flags parse will see these values // like the default ones. It will overwrite them only if the same option diff --git a/pkg/commands/version.go b/pkg/commands/version.go new file mode 100644 index 00000000..fdb5aa88 --- /dev/null +++ b/pkg/commands/version.go @@ -0,0 +1,17 @@ +package commands + +import ( + "github.com/spf13/cobra" +) + +func (e *Executor) initVersion() { + versionCmd := &cobra.Command{ + Use: "version", + Short: "Version", + Run: func(cmd *cobra.Command, _ []string) { + cmd.Printf("golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date) + }, + } + + e.rootCmd.AddCommand(versionCmd) +}