From bee5df3530df01b76b00e02194da011871419eb8 Mon Sep 17 00:00:00 2001 From: buty4649 Date: Tue, 19 Mar 2024 00:32:55 +0900 Subject: [PATCH] Update version formatting in Execute function --- cmd/root.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 0d55cfa..4caeaf9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -22,6 +22,7 @@ SOFTWARE. package cmd import ( + "fmt" "log/slog" "os" @@ -42,7 +43,6 @@ var ip *iproute2.Iproute2 var rootCmd = &cobra.Command{ Use: "netnsplan", - Version: version.Version, Short: "Easily automate Linux netns networks and configurations via YAML", Long: "Easily automate Linux netns networks and configurations via YAML", SilenceUsage: true, @@ -69,6 +69,12 @@ var rootCmd = &cobra.Command{ } func Execute() { + if version.Version != "dev" { + rootCmd.Version = fmt.Sprintf("v%s", version.Version) + } else { + rootCmd.Version = version.Version + } + err := rootCmd.Execute() if err != nil { os.Exit(1)