Skip to content

Commit 25ce7e8

Browse files
committed
fix: build version
1 parent d146aad commit 25ce7e8

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

cmd/root.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ import (
77
"github.com/spf13/cobra"
88
)
99

10-
var versionStr = "dev"
11-
12-
func SetVersion(s string) {
13-
versionStr = s
14-
}
15-
1610
var rootCmd = &cobra.Command{
1711
Use: "gn",
1812
Short: "Glassnode API command-line interface",
@@ -22,22 +16,26 @@ var rootCmd = &cobra.Command{
2216
},
2317
}
2418

25-
func Execute() {
26-
if err := rootCmd.Execute(); err != nil {
27-
fmt.Fprintln(os.Stderr, err)
28-
os.Exit(1)
29-
}
30-
}
31-
3219
func init() {
20+
rootCmd.Version = "dev"
3321
rootCmd.PersistentFlags().String("api-key", "", "API key override")
3422
rootCmd.PersistentFlags().StringP("output", "o", "json", "output format: json, csv, table")
3523
rootCmd.PersistentFlags().Bool("dry-run", false, "print the request URL without executing")
3624
rootCmd.PersistentFlags().String("timestamp-format", "humanized", "timestamp format: unix, humanized, or Go layout (e.g. 2006-01-02 15:04:05); applies to table/csv output")
37-
rootCmd.Version = versionStr
3825
rootCmd.SetVersionTemplate("gn version {{.Version}}\n")
3926

4027
rootCmd.AddCommand(configCmd)
4128
rootCmd.AddCommand(metricCmd)
4229
rootCmd.AddCommand(assetCmd)
4330
}
31+
32+
func SetVersion(v string) {
33+
rootCmd.Version = v
34+
}
35+
36+
func Execute() {
37+
if err := rootCmd.Execute(); err != nil {
38+
fmt.Fprintln(os.Stderr, err)
39+
os.Exit(1)
40+
}
41+
}

0 commit comments

Comments
 (0)