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)) }