Fix refresh limit flag default

pull/38/head
Miguel Mota 5 years ago
parent 26871444c3
commit 52496b87fb
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -10,6 +10,7 @@ import (
// Run ... // Run ...
func Run() { func Run() {
var v, ver, test, clean, reset, hideMarketbar, hideChart, hideStatusbar, onlyTable bool var v, ver, test, clean, reset, hideMarketbar, hideChart, hideStatusbar, onlyTable bool
var refreshRate uint
var config, cmcAPIKey, apiChoice, colorscheme string var config, cmcAPIKey, apiChoice, colorscheme string
flag.BoolVar(&v, "v", false, "Version") flag.BoolVar(&v, "v", false, "Version")
flag.BoolVar(&ver, "version", false, "Display current 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(&hideChart, "hide-chart", false, "Hide the chart view")
flag.BoolVar(&hideStatusbar, "hide-statusbar", false, "Hide the bottom statusbar") 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") 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.UintVar(&refreshRate, "refresh-rate", 60, "Refresh rate in seconds. Set to 0 to not auto-refresh")
flag.StringVar(&config, "config", "", "Config filepath. Default is ~/.cointop/config.toml") flag.StringVar(&config, "config", "", "Config filepath. (default ~/.cointop/config.toml)")
flag.StringVar(&cmcAPIKey, "coinmarketcap-api-key", "", "Set the CoinMarketCap API key") flag.StringVar(&cmcAPIKey, "coinmarketcap-api-key", "", "Set the CoinMarketCap API key")
flag.StringVar(&apiChoice, "api", cointop.CoinGecko, "API choice") flag.StringVar(&apiChoice, "api", cointop.CoinGecko, "API choice. Available choices are \"coinmarketcap\" and \"coingecko\"")
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(&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() flag.Parse()
var refreshRate *uint refreshRateFlagFound := false
if refreshRateFlag != nil { var refreshRateP *uint
if *refreshRateFlag > -1 { flag.Visit(func(f *flag.Flag) {
t := uint(*refreshRateFlag) if f.Name == "refresh-rate" {
refreshRate = &t refreshRateFlagFound = true
} }
})
if refreshRateFlagFound {
refreshRateP = &refreshRate
} }
if v || ver { if v || ver {
@ -53,7 +58,7 @@ func Run() {
HideChart: hideChart, HideChart: hideChart,
HideStatusbar: hideStatusbar, HideStatusbar: hideStatusbar,
OnlyTable: onlyTable, OnlyTable: onlyTable,
RefreshRate: refreshRate, RefreshRate: refreshRateP,
}).Run() }).Run()
} }
} }

Loading…
Cancel
Save