diff --git a/cmd/root.go b/cmd/root.go index 07e07cd..c8dd385 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -6,6 +6,7 @@ import ( "os/signal" "path/filepath" "regexp" + "runtime/debug" "strings" "github.com/pterm/pterm" @@ -83,7 +84,7 @@ func init() { rootCmd.AddCommand(project.ProjectCmd) // Version - rootCmd.Version = Version + rootCmd.Version = getVersion() } // initConfig reads in config file and ENV variables if set. @@ -172,3 +173,10 @@ func checkConfigPerms(file string) { os.Exit(1) } } + +func getVersion() string { + if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" { + return info.Main.Version + } + return Version +}