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.`,
|
2023-12-29 15:24:12 +00:00
|
|
|
PreRun: runCacheCmd,
|
|
|
|
PostRun: postCacheCmd,
|
|
|
|
Run: loadCache,
|
2023-12-07 17:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func loadCache(cmd *cobra.Command, args []string) {
|
|
|
|
cache.Refresh()
|
2023-12-04 21:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cacheCmd.AddCommand(loadCmd)
|
2023-12-10 04:19:19 +00:00
|
|
|
|
|
|
|
loadCmd.PersistentFlags().Bool("ownerOnly", true,
|
|
|
|
"Only load projects that you are owner of")
|
|
|
|
|
|
|
|
viper.BindPFlag("cache.load.ownerOnly", loadCmd.Flag("ownerOnly"))
|
2023-12-04 21:53:01 +00:00
|
|
|
}
|