package cache import ( "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/spf13/viper" "gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util" ) var unlockCmd = &cobra.Command{ Use: "unlock", Short: "unlock Git project cache", Long: `unlocks cache to display`, Run: func(cmd *cobra.Command, args []string) { utils = util.MustFromCtx(cmd.Context()) utils.InitProjectCache(cmd, args) if viper.GetBool(util.ViperCacheUnlockForce) { utils.Cache().UnlockCache() } else if yes, _ := pterm.DefaultInteractiveConfirm. WithDefaultValue(false). Show("Are you sure you want to manually unlock?"); yes { utils.Cache().UnlockCache() } else { utils.Logger().Error("You failed to confirm cache unlock") } }, } func init() { unlockCmd.PersistentFlags().BoolP(util.FlagCacheForce, "f", false, "force unlocks cache (don't ask)") viper.BindPFlag(util.ViperCacheUnlockForce, unlockCmd.LocalFlags().Lookup(util.FlagCacheForce)) }