Set version command output to Stdout (#1869)
This commit is contained in:
parent
82778e2f9f
commit
814bf0e0ad
@ -2,6 +2,7 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -35,7 +36,7 @@ func (e *Executor) initVersion() {
|
|||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
switch strings.ToLower(e.cfg.Version.Format) {
|
switch strings.ToLower(e.cfg.Version.Format) {
|
||||||
case "short":
|
case "short":
|
||||||
cmd.Println(e.version)
|
fmt.Println(e.version)
|
||||||
case "json":
|
case "json":
|
||||||
ver := jsonVersion{
|
ver := jsonVersion{
|
||||||
Version: e.version,
|
Version: e.version,
|
||||||
@ -46,9 +47,9 @@ func (e *Executor) initVersion() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd.Println(string(data))
|
fmt.Println(string(data))
|
||||||
default:
|
default:
|
||||||
cmd.Printf("golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date)
|
fmt.Printf("golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user