mirror of https://github.com/miguelmota/cointop
Clean the configured cache_dir not /tmp
parent
f375eec1eb
commit
be40f267d4
@ -1,29 +1,38 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cointop-sh/cointop/cointop"
|
||||
"github.com/cointop-sh/cointop/pkg/filecache"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// CleanCmd ...
|
||||
func CleanCmd() *cobra.Command {
|
||||
cacheDir := filecache.DefaultCacheDir
|
||||
var config string
|
||||
|
||||
cleanCmd := &cobra.Command{
|
||||
Use: "clean",
|
||||
Short: "Clear the cache",
|
||||
Long: `The clean command clears the cache`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// Load config etc
|
||||
ct, err := cointop.NewCointop(&cointop.Config{
|
||||
ConfigFilepath: config,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// NOTE: if clean command, clean but don't run cointop
|
||||
return cointop.Clean(&cointop.CleanConfig{
|
||||
Log: true,
|
||||
CacheDir: cacheDir,
|
||||
CacheDir: ct.State.GetCacheDir(),
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
cleanCmd.Flags().StringVarP(&cacheDir, "cache-dir", "", cacheDir, "Cache directory")
|
||||
cleanCmd.Flags().StringVarP(&config, "config", "c", "", fmt.Sprintf("Config filepath. (default %s)", cointop.DefaultConfigFilepath))
|
||||
|
||||
return cleanCmd
|
||||
}
|
||||
|
Loading…
Reference in New Issue