32 lines
830 B
Go
32 lines
830 B
Go
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)
|
|
if viper.GetBool("cache.unlock.force") {
|
|
cache.UnlockCache()
|
|
} else if yes, _ := pterm.DefaultInteractiveConfirm.
|
|
WithDefaultValue(false).
|
|
Show("Are you sure you want to manually unlock?"); yes {
|
|
cache.UnlockCache()
|
|
} else {
|
|
plog.Error("You failed to confirm cache unlock")
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
cacheCmd.AddCommand(unlockCmd)
|
|
unlockCmd.PersistentFlags().BoolP("force", "f", false, "force unlocks cache (don't ask)")
|
|
viper.BindPFlag("cache.unlock.force", unlockCmd.LocalFlags().Lookup("force"))
|
|
}
|