Skip to content

Commit

Permalink
fix gorelease version passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
bitte-ein-bit committed Nov 28, 2023
1 parent 2833015 commit 6257837
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import (
"github.com/spf13/viper"
)

var VERSION = "unreleased"

var cfgFile string

var RootCmd = &cobra.Command{Use: "clisso", Version: VERSION}
var RootCmd = &cobra.Command{Use: "clisso", Version: "0.0.0"}

const usageTemplate = `Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
Expand Down Expand Up @@ -73,8 +71,10 @@ func init() {
RootCmd.SetVersionTemplate(versionTemplate)
}

func Execute(version string) {
VERSION = version
func Execute(version, commit, date string) {
// transfer version from main to cmd
// format as "0.0.0 (commit date)"
RootCmd.Version = version + " (" + commit + " " + date + ")"
err := RootCmd.Execute()
if err != nil {
log.Fatalf("Failed to execute: %v", err)
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import (
)

// This variable is used by the "version" command and is set during build.
var version = "undefined"
var (
version = "dev"
commit = "none"
date = "unknown"
)

func main() {
log.SetFlags(log.Flags() &^ (log.Ldate | log.Ltime))
Expand All @@ -25,5 +29,5 @@ func main() {
log.SetOutput(colorable.NewColorableStdout())
}

cmd.Execute(version)
cmd.Execute(version, commit, date)
}

0 comments on commit 6257837

Please sign in to comment.