From e105846488e35df66616ed673a15d6519f2d25b1 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 29 Apr 2024 23:59:33 -0400 Subject: [PATCH] fix: use version info from goreleaser --- cmd/root.go | 8 ++++---- main.go | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index d609787..b76e5c3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -9,9 +9,8 @@ import ( // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Version: "v0.0.5", - Use: "ddns", - Short: "A simple DDNS server and client", + Use: "ddns", + Short: "A simple DDNS server and client", Long: fmt.Sprintf(`A simple DDNS server and client. ENVIRONMENT VARIABLES @@ -23,7 +22,8 @@ ENVIRONMENT VARIABLES // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() { +func Execute(version string) { + rootCmd.Version = version err := rootCmd.Execute() if err != nil { os.Exit(1) diff --git a/main.go b/main.go index d8d1a94..6db7c1c 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,17 @@ package main -import "github.com/tnyeanderson/ddns/cmd" +import ( + "fmt" + + "github.com/tnyeanderson/ddns/cmd" +) + +// These get populated by goreleaser +var ( + version = "dev" + commit = "none" +) func main() { - cmd.Execute() + cmd.Execute(fmt.Sprintf("%s commit:%s", version, commit)) }