mirror of https://github.com/miguelmota/cointop
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.
43 lines
954 B
Go
43 lines
954 B
Go
package cmd
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
|
|
"github.com/miguelmota/cointop/cointop"
|
|
)
|
|
|
|
// Run ...
|
|
func Run() {
|
|
var v, ver, test, clean, reset bool
|
|
var config, cmcAPIKey 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.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,
|
|
}).Run()
|
|
}
|
|
}
|
|
|
|
func doTest() {
|
|
cointop.NewCointop(&cointop.Config{
|
|
NoPrompts: true,
|
|
}).Exit()
|
|
}
|