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