2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-16 21:25:38 +00:00
cointop/cmd/commands/reset.go

39 lines
956 B
Go
Raw Normal View History

2020-08-10 01:42:04 +00:00
package cmd
import (
"fmt"
"os"
2021-09-30 06:17:58 +00:00
"github.com/cointop-sh/cointop/cointop"
2020-08-10 01:42:04 +00:00
"github.com/spf13/cobra"
)
// ResetCmd will wipe cache and config file
2020-08-10 01:42:04 +00:00
func ResetCmd() *cobra.Command {
config := os.Getenv("COINTOP_CONFIG")
cacheDir := os.Getenv("COINTOP_CACHE_DIR")
2020-08-10 01:42:04 +00:00
resetCmd := &cobra.Command{
Use: "reset",
Short: "Resets the config and clear the cache",
Long: `The reset command resets the config and clears the cache`,
RunE: func(cmd *cobra.Command, args []string) error {
ct, err := cointop.NewCointop(&cointop.Config{
ConfigFilepath: config,
})
if err != nil {
return err
}
return ct.Reset(&cointop.ResetConfig{
2020-08-10 01:42:04 +00:00
Log: true,
CacheDir: cacheDir,
})
},
}
resetCmd.Flags().StringVarP(&cacheDir, "cache-dir", "", cacheDir, "Cache directory")
resetCmd.Flags().StringVarP(&config, "config", "c", config, fmt.Sprintf("Config filepath. (default %s)", cointop.DefaultConfigFilepath))
2020-08-10 01:42:04 +00:00
return resetCmd
}