git-project-manager/cmd/cache.go
2024-12-19 14:55:49 -05:00

38 lines
778 B
Go

package cmd
import (
"time"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/cache"
)
var projectCache *cache.Cache
var cacheCmd = &cobra.Command{
Use: "cache",
Aliases: []string{"a", "ln"},
Short: "Manage GitLab project cache",
Long: cacheCmdLong,
}
func runCacheCmd(cmd *cobra.Command, args []string) {
initProjectCache(cmd, args)
projectCache.LockCache()
}
func postCacheCmd(cmd *cobra.Command, args []string) {
postProjectCache(cmd, args)
projectCache.UnlockCache()
}
func init() {
rootCmd.AddCommand(cacheCmd)
cacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
"Duration before cache is re-built in go time.Duration format")
viper.BindPFlags(cacheCmd.Flags())
}