-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
36 lines (30 loc) · 791 Bytes
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package version
import (
"fmt"
"github.com/fs714/github-star-manager/pkg/utils/version"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var StartCmd = &cobra.Command{
Use: "version",
Short: "Show version information",
Run: func(cmd *cobra.Command, args []string) {
printVersion()
},
}
func InitStartCmd() {
StartCmd.SetHelpFunc(func(command *cobra.Command, strings []string) {
command.Parent().PersistentFlags().VisitAll(func(flag *pflag.Flag) {
flag.Hidden = true
})
command.Parent().HelpFunc()(command, strings)
})
}
func printVersion() {
versionInfo := `Version Information:
Version: %s
Commit: %s
Build Time: %s
Go Version: %s`
fmt.Println(fmt.Sprintf(versionInfo, version.BaseVersion, version.GitVersion, version.BuildTime, version.GoVersion))
}