Skip to content

Commit 5e54b33

Browse files
jimen0tpounds
authored andcommitted
Add version command to print golangci-lint version
Fixes #675
1 parent 6d786b5 commit 5e54b33

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/commands/executor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func NewExecutor(version, commit, date string) *Executor {
8282
e.initLinters()
8383
e.initConfig()
8484
e.initCompletion()
85+
e.initVersion()
8586

8687
// init e.cfg by values from config: flags parse will see these values
8788
// like the default ones. It will overwrite them only if the same option

pkg/commands/version.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package commands
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
func (e *Executor) initVersion() {
8+
versionCmd := &cobra.Command{
9+
Use: "version",
10+
Short: "Version",
11+
Run: func(cmd *cobra.Command, _ []string) {
12+
cmd.Printf("golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date)
13+
},
14+
}
15+
16+
e.rootCmd.AddCommand(versionCmd)
17+
}

0 commit comments

Comments
 (0)