diff --git a/cmd/cointop.go b/cmd/cointop.go index ec27479..8a9db92 100644 --- a/cmd/cointop.go +++ b/cmd/cointop.go @@ -10,6 +10,7 @@ import ( // Run ... func Run() { var v, ver, test, clean, reset, hideMarketbar, hideChart, hideStatusbar, onlyTable bool + var refreshRate uint var config, cmcAPIKey, apiChoice, colorscheme string flag.BoolVar(&v, "v", false, "Version") flag.BoolVar(&ver, "version", false, "Display current version") @@ -20,19 +21,23 @@ func Run() { flag.BoolVar(&hideChart, "hide-chart", false, "Hide the chart view") flag.BoolVar(&hideStatusbar, "hide-statusbar", false, "Hide the bottom statusbar") flag.BoolVar(&onlyTable, "only-table", false, "Show only the table. Hides the chart and top and bottom bars") - refreshRateFlag := flag.Int("refresh-rate", -1, "Refresh rate in seconds. Set to 0 to not auto-refresh. Default is 60") - flag.StringVar(&config, "config", "", "Config filepath. Default is ~/.cointop/config.toml") + flag.UintVar(&refreshRate, "refresh-rate", 60, "Refresh rate in seconds. Set to 0 to not auto-refresh") + flag.StringVar(&config, "config", "", "Config filepath. (default ~/.cointop/config.toml)") flag.StringVar(&cmcAPIKey, "coinmarketcap-api-key", "", "Set the CoinMarketCap API key") - flag.StringVar(&apiChoice, "api", cointop.CoinGecko, "API choice") - flag.StringVar(&colorscheme, "colorscheme", "", "Colorscheme to use. Default is \"cointop\". To install standard themes, do:\n\ngit clone git@github.com:cointop-sh/colors.git ~/.cointop/colors\n\nFor additional instructions, visit: https://github.com/cointop-sh/colors") + flag.StringVar(&apiChoice, "api", cointop.CoinGecko, "API choice. Available choices are \"coinmarketcap\" and \"coingecko\"") + flag.StringVar(&colorscheme, "colorscheme", "", "Colorscheme to use (defualt \"cointop\"). To install standard themes, do:\n\ngit clone git@github.com:cointop-sh/colors.git ~/.cointop/colors\n\nFor additional instructions, visit: https://github.com/cointop-sh/colors") flag.Parse() - var refreshRate *uint - if refreshRateFlag != nil { - if *refreshRateFlag > -1 { - t := uint(*refreshRateFlag) - refreshRate = &t + refreshRateFlagFound := false + var refreshRateP *uint + flag.Visit(func(f *flag.Flag) { + if f.Name == "refresh-rate" { + refreshRateFlagFound = true } + }) + + if refreshRateFlagFound { + refreshRateP = &refreshRate } if v || ver { @@ -53,7 +58,7 @@ func Run() { HideChart: hideChart, HideStatusbar: hideStatusbar, OnlyTable: onlyTable, - RefreshRate: refreshRate, + RefreshRate: refreshRateP, }).Run() } }