diff --git a/command/tectl/cmd/root.go b/command/tectl/cmd/root.go index e0b303d..7df679f 100644 --- a/command/tectl/cmd/root.go +++ b/command/tectl/cmd/root.go @@ -8,25 +8,26 @@ import ( ) var ( - Version string + VERSION string RootCmd = &cobra.Command{ Use: "tectl", Short: "tectl is a cli tool for managing thousandeyes", Long: "tectl is a cli tool for managing thousandeyes and querying the existing configuration", Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("tectl version: %s", Version) + fmt.Printf("tectl version: %s", VERSION) }, } versionCmd = &cobra.Command{ Use: "version", Short: "Print the version number of tectl", Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("version: %s", Version) + fmt.Printf("version: %s", VERSION) }, } ) -func Execute() error { +func Execute(version string) error { + VERSION = version return RootCmd.Execute() } diff --git a/command/tectl/main.go b/command/tectl/main.go index 60a725f..8e0bd0b 100644 --- a/command/tectl/main.go +++ b/command/tectl/main.go @@ -4,6 +4,10 @@ import ( "github.com/william20111/go-thousandeyes/command/tectl/cmd" ) +var ( + Version string +) + func main() { - cmd.Execute() + cmd.Execute(Version) }