Skip to content

Commit

Permalink
Fix version passing
Browse files Browse the repository at this point in the history
  • Loading branch information
riley-martine committed Feb 19, 2023
1 parent fe39d8f commit b2cb02d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 4 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"github.com/spf13/cobra"
)

// Set by goreleaser:
// https://goreleaser.com/cookbooks/using-main.version/?h=version
var version = "dev"

var (
debug bool
cityName string
Expand All @@ -24,9 +20,8 @@ var (
)

var rootCmd = &cobra.Command{
Use: "sundial --city CITY",
Short: "Print the percent through the day or night.",
Version: version,
Use: "sundial --city CITY",
Short: "Print the percent through the day or night.",
Long: `Sundial is a program to print the percent through the day or night.
https://github.com/riley-martine/sundial`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -85,7 +80,8 @@ Not required if only one city in country with name.`)
rootCmd.Flags().StringVar(&givenTime, "time", "", "Time to convert, in time.UnixDate format. Defaults to now.")
}

func Execute() {
func Execute(version string) {
rootCmd.Version = version
if err := rootCmd.Execute(); err != nil {
// fmt.Fprintln(os.Stderr, err)
os.Exit(1)
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import (
"github.com/riley-martine/sundial/cmd"
)

// Set by goreleaser:
// https://goreleaser.com/cookbooks/using-main.version/?h=version
var version = "dev"

func main() {
cmd.Execute()
cmd.Execute(version)
}

0 comments on commit b2cb02d

Please sign in to comment.