2023-12-04 21:53:01 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2023-12-05 21:56:47 +00:00
|
|
|
"time"
|
2023-12-04 21:53:01 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2023-12-05 21:56:47 +00:00
|
|
|
"github.com/spf13/viper"
|
2024-12-27 22:42:44 +00:00
|
|
|
|
2024-12-19 19:55:49 +00:00
|
|
|
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/cache"
|
2023-12-04 21:53:01 +00:00
|
|
|
)
|
|
|
|
|
2024-01-15 21:02:15 +00:00
|
|
|
var projectCache *cache.Cache
|
2023-12-05 21:56:47 +00:00
|
|
|
|
2023-12-04 21:53:01 +00:00
|
|
|
var cacheCmd = &cobra.Command{
|
2023-12-29 15:24:12 +00:00
|
|
|
Use: "cache",
|
|
|
|
Aliases: []string{"a", "ln"},
|
2024-12-27 22:42:44 +00:00
|
|
|
Short: "Manage Git project cache",
|
2023-12-29 15:24:12 +00:00
|
|
|
Long: cacheCmdLong,
|
2023-12-05 21:56:47 +00:00
|
|
|
}
|
|
|
|
|
2023-12-10 05:05:39 +00:00
|
|
|
func runCacheCmd(cmd *cobra.Command, args []string) {
|
2023-12-05 21:56:47 +00:00
|
|
|
initProjectCache(cmd, args)
|
2024-01-15 21:02:15 +00:00
|
|
|
projectCache.LockCache()
|
2023-12-05 21:56:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func postCacheCmd(cmd *cobra.Command, args []string) {
|
|
|
|
postProjectCache(cmd, args)
|
2024-01-15 21:02:15 +00:00
|
|
|
projectCache.UnlockCache()
|
2023-12-04 21:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(cacheCmd)
|
|
|
|
|
2023-12-05 21:56:47 +00:00
|
|
|
cacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
|
|
|
|
"Duration before cache is re-built in go time.Duration format")
|
2023-12-04 21:53:01 +00:00
|
|
|
|
2023-12-05 21:56:47 +00:00
|
|
|
viper.BindPFlags(cacheCmd.Flags())
|
2023-12-04 21:53:01 +00:00
|
|
|
}
|