Package subcommand code

This commit is contained in:
2024-12-30 15:50:31 -05:00
parent 96378d047e
commit b9d7d5a4f2
51 changed files with 357 additions and 295 deletions

View File

@@ -1,9 +1,11 @@
package cmd
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{
@@ -11,21 +13,21 @@ var unlockCmd = &cobra.Command{
Short: "unlock Git project cache",
Long: `unlocks cache to display`,
Run: func(cmd *cobra.Command, args []string) {
initProjectCache(cmd, args)
if viper.GetBool(ViperCacheUnlockForce) {
projectCache.UnlockCache()
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 {
projectCache.UnlockCache()
utils.Cache().UnlockCache()
} else {
plog.Error("You failed to confirm cache unlock")
utils.Logger().Error("You failed to confirm cache unlock")
}
},
}
func init() {
cacheCmd.AddCommand(unlockCmd)
unlockCmd.PersistentFlags().BoolP(FlagCacheForce, "f", false, "force unlocks cache (don't ask)")
viper.BindPFlag(ViperCacheUnlockForce, unlockCmd.LocalFlags().Lookup(FlagCacheForce))
unlockCmd.PersistentFlags().BoolP(util.FlagCacheForce, "f", false, "force unlocks cache (don't ask)")
viper.BindPFlag(util.ViperCacheUnlockForce, unlockCmd.LocalFlags().Lookup(util.FlagCacheForce))
}