From ab54b7c3c2b6f654b7c6379f994029e0270fedf2 Mon Sep 17 00:00:00 2001 From: Christof Laenzlinger <6319634+laenzlinger@users.noreply.github.com> Date: Sun, 31 Mar 2024 22:40:51 +0200 Subject: [PATCH] Use the version info set by goreleaser --- cmd/root.go | 4 +++- main.go | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index a158abe..43b5132 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -43,7 +43,9 @@ var rootCmd = &cobra.Command{ // 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 f91f906..55d7bd1 100644 --- a/main.go +++ b/main.go @@ -16,8 +16,19 @@ along with this program. If not, see . */ package main -import "github.com/laenzlinger/setlist/cmd" +import ( + "fmt" + + "github.com/laenzlinger/setlist/cmd" +) + +var ( + version = "dev" + commit = "none" //nolint:gochecknoglobals // set by ldflag + date = "unknown" //nolint:gochecknoglobals // set by ldflag + +) func main() { - cmd.Execute() + cmd.Execute(fmt.Sprintf("%s commit %s (%s) ", version, commit, date)) }