git-project-manager/cmd/cache_load.go

32 lines
758 B
Go
Raw Normal View History

2023-12-04 21:53:01 +00:00
package cmd
import (
"github.com/spf13/cobra"
2023-12-10 04:19:19 +00:00
"github.com/spf13/viper"
2023-12-04 21:53:01 +00:00
)
var loadCmd = &cobra.Command{
Use: "load",
2023-12-05 21:56:47 +00:00
Short: "Load GitLab Project Cache",
Long: `Used to initialize or update a new GitLab cache. With thousands
of projects, it would be too much work to hit the API every time a user
wants to find a new project.`,
PreRun: runCacheCmd,
PostRun: postCacheCmd,
Run: loadCache,
2023-12-07 17:08:56 +00:00
}
func loadCache(cmd *cobra.Command, args []string) {
2024-10-01 18:29:14 +00:00
remotes := viper.GetStringSlice(FlagRemote)
projectCache.Refresh(remotes...)
2023-12-04 21:53:01 +00:00
}
func init() {
cacheCmd.AddCommand(loadCmd)
2023-12-10 04:19:19 +00:00
2024-10-01 18:29:14 +00:00
loadCmd.PersistentFlags().Bool(FlagOwnerOnly, true,
2023-12-10 04:19:19 +00:00
"Only load projects that you are owner of")
2024-10-01 18:29:14 +00:00
viper.BindPFlag(ViperCacheLoadOwnerOnly, loadCmd.Flag(FlagOwnerOnly))
2023-12-04 21:53:01 +00:00
}