You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cointop/cmd/cointop.go

47 lines
1.2 KiB
Go

package cmd
import (
"flag"
"fmt"
"github.com/miguelmota/cointop/cointop"
)
// Run ...
func Run() {
var v, ver, test, clean, reset bool
var config, cmcAPIKey, apiChoice, colorscheme string
flag.BoolVar(&v, "v", false, "Version")
flag.BoolVar(&ver, "version", false, "Version")
flag.BoolVar(&test, "test", false, "Run test")
flag.BoolVar(&clean, "clean", false, "Clean cache")
flag.BoolVar(&reset, "reset", false, "Reset config")
flag.StringVar(&config, "config", "", "Config filepath")
flag.StringVar(&cmcAPIKey, "coinmarketcap-api-key", "", "CoinMarketCap API key")
flag.StringVar(&apiChoice, "api", cointop.CoinGecko, "API choice")
flag.StringVar(&colorscheme, "colorscheme", "", "Colorscheme name")
flag.Parse()
if v || ver {
fmt.Printf("cointop v%s", cointop.Version())
} else if test {
doTest()
} else if clean {
cointop.Clean()
} else if reset {
cointop.Reset()
} else {
cointop.NewCointop(&cointop.Config{
ConfigFilepath: config,
CoinMarketCapAPIKey: cmcAPIKey,
APIChoice: apiChoice,
Colorscheme: colorscheme,
}).Run()
}
}
func doTest() {
cointop.NewCointop(&cointop.Config{
NoPrompts: true,
}).Exit()
}