2023-12-29 15:24:12 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pterm/pterm"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
var unlockCmd = &cobra.Command{
|
|
|
|
Use: "unlock",
|
|
|
|
Short: "unlock GitLab project cache",
|
|
|
|
Long: `unlocks cache to display`,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
initProjectCache(cmd, args)
|
2024-10-01 18:29:14 +00:00
|
|
|
if viper.GetBool(ViperCacheUnlockForce) {
|
2024-01-15 21:02:15 +00:00
|
|
|
projectCache.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-01-15 21:02:15 +00:00
|
|
|
projectCache.UnlockCache()
|
2023-12-29 15:24:12 +00:00
|
|
|
} else {
|
|
|
|
plog.Error("You failed to confirm cache unlock")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cacheCmd.AddCommand(unlockCmd)
|
2024-10-01 18:29:14 +00:00
|
|
|
unlockCmd.PersistentFlags().BoolP(FlagCacheForce, "f", false, "force unlocks cache (don't ask)")
|
|
|
|
viper.BindPFlag(ViperCacheUnlockForce, unlockCmd.LocalFlags().Lookup(FlagCacheForce))
|
2023-12-29 15:24:12 +00:00
|
|
|
}
|