Package subcommand code
This commit is contained in:
31
cmd/cache/cache.go
vendored
31
cmd/cache/cache.go
vendored
@@ -1,34 +1,43 @@
|
||||
package cmd
|
||||
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{
|
||||
var CacheCmd = &cobra.Command{
|
||||
Use: "cache",
|
||||
Aliases: []string{"a", "ln"},
|
||||
Short: "Manage Git project cache",
|
||||
Long: cacheCmdLong,
|
||||
Long: util.CacheCmdLong,
|
||||
}
|
||||
|
||||
var utils *util.Utils
|
||||
|
||||
func runCacheCmd(cmd *cobra.Command, args []string) {
|
||||
initProjectCache(cmd, args)
|
||||
projectCache.LockCache()
|
||||
utils = util.MustFromCtx(cmd.Context())
|
||||
|
||||
utils.InitProjectCache(cmd, args)
|
||||
utils.Cache().LockCache()
|
||||
}
|
||||
|
||||
func postCacheCmd(cmd *cobra.Command, args []string) {
|
||||
postProjectCache(cmd, args)
|
||||
projectCache.UnlockCache()
|
||||
utils.PostProjectCache(cmd, args)
|
||||
utils.Cache().UnlockCache()
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(cacheCmd)
|
||||
|
||||
cacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
|
||||
CacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
|
||||
"Duration before cache is re-built in go time.Duration format")
|
||||
|
||||
viper.BindPFlags(cacheCmd.Flags())
|
||||
viper.BindPFlags(CacheCmd.Flags())
|
||||
|
||||
CacheCmd.AddCommand(clearCmd)
|
||||
CacheCmd.AddCommand(dumpCmd)
|
||||
CacheCmd.AddCommand(loadCmd)
|
||||
CacheCmd.AddCommand(unlockCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user