Skip to content

Commit b17ce0e

Browse files
committed
Add version cmd
1 parent 0ed9a67 commit b17ce0e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

cmd/oauth2.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ func OAuth2Cmd() *cobra.Command {
9696
},
9797
}
9898

99+
cmd.AddCommand(versionCmd)
100+
99101
cmd.PersistentFlags().StringVar(&cconfig.ClientID, "client-id", "", "client identifier")
100102
cmd.PersistentFlags().StringVar(&cconfig.ClientSecret, "client-secret", "", "client secret")
101103
cmd.PersistentFlags().StringVar(&cconfig.GrantType, "grant-type", "", "grant type")

cmd/version.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"runtime/debug"
6+
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var versionCmd = &cobra.Command{
11+
Use: "version",
12+
Short: "Display version",
13+
Run: func(cmd *cobra.Command, args []string) {
14+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {
15+
fmt.Println(info)
16+
} else {
17+
fmt.Println("unknown")
18+
}
19+
},
20+
}

0 commit comments

Comments
 (0)