git-project-manager/cmd/cache_clear.go

32 lines
826 B
Go
Raw Normal View History

2023-12-07 17:08:56 +00:00
package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/exp/slog"
)
const longDesc = `Used to reset a project cache, forcing it to be rebuilt.
If --clearAliases is provided, will also reset aliases. Use with caution.`
var clearCmd = &cobra.Command{
Use: "clear",
Short: "Clear GitLab Project Cache",
PreRun: runCacheCmd,
PostRun: postCacheCmd,
Long: longDesc,
Run: clearCache,
2023-12-07 17:08:56 +00:00
}
func clearCache(cmd *cobra.Command, args []string) {
slog.Debug("Preparing to clear local cache")
cache.Clear(conf.Cache.Clear.ClearAliases)
}
func init() {
cacheCmd.AddCommand(clearCmd)
clearCmd.Flags().Bool("clearAliases", false, "Will also clear aliases from the cache, use with caution")
viper.BindPFlag("cache.clear.clearAliases", clearCmd.LocalFlags().Lookup("clearAliases"))
}