Clean the configured cache_dir not /tmp

pull/193/head
Simon Roberts 3 years ago
parent f375eec1eb
commit be40f267d4
No known key found for this signature in database
GPG Key ID: 0F30F99E6B771FD4

@ -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
}

@ -66,3 +66,8 @@ func normalizeFloatString(input string, allowNegative bool) string {
return ""
}
// GetCacheDir ...
func (state *State) GetCacheDir() string {
return state.cacheDir
}

Loading…
Cancel
Save