File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,12 @@ var rootCmd = &cobra.Command{
8181 },
8282}
8383
84+ // SetVersionInfo sets the version information for the root command.
85+ func SetVersionInfo (version , buildDate string ) {
86+ rootCmd .Version = version
87+ rootCmd .SetVersionTemplate (fmt .Sprintf ("nomore403 version %s (built %s)\n " , version , buildDate ))
88+ }
89+
8490// Execute adds all child commands to the root command and sets flags appropriately.
8591// This is called by main.main(). It only needs to happen once to the rootCmd.
8692func Execute () {
Original file line number Diff line number Diff line change @@ -4,6 +4,13 @@ package main
44
55import "github.com/devploit/nomore403/cmd"
66
7+ // Version and BuildDate are set via ldflags at build time.
8+ var (
9+ Version = "dev"
10+ BuildDate = "unknown"
11+ )
12+
713func main () {
14+ cmd .SetVersionInfo (Version , BuildDate )
815 cmd .Execute ()
916}
You can’t perform that action at this time.
0 commit comments