@@ -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-
1610var 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-
3219func 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