44 lines
918 B
Go
44 lines
918 B
Go
package cache
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
|
|
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
|
)
|
|
|
|
var CacheCmd = &cobra.Command{
|
|
Use: "cache",
|
|
Aliases: []string{"a", "ln"},
|
|
Short: "Manage Git project cache",
|
|
Long: util.CacheCmdLong,
|
|
}
|
|
|
|
var utils *util.Utils
|
|
|
|
func runCacheCmd(cmd *cobra.Command, args []string) {
|
|
utils = util.MustFromCtx(cmd.Context())
|
|
|
|
utils.InitProjectCache(cmd, args)
|
|
utils.Cache().LockCache()
|
|
}
|
|
|
|
func postCacheCmd(cmd *cobra.Command, args []string) {
|
|
utils.PostProjectCache(cmd, args)
|
|
utils.Cache().UnlockCache()
|
|
}
|
|
|
|
func init() {
|
|
CacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
|
|
"Duration before cache is re-built in go time.Duration format")
|
|
|
|
viper.BindPFlags(CacheCmd.Flags())
|
|
|
|
CacheCmd.AddCommand(clearCmd)
|
|
CacheCmd.AddCommand(dumpCmd)
|
|
CacheCmd.AddCommand(loadCmd)
|
|
CacheCmd.AddCommand(unlockCmd)
|
|
}
|