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",
|
2024-12-27 22:42:44 +00:00
|
|
|
Short: "Load Git Project Cache",
|
|
|
|
Long: `Used to initialize or update a new Git cache. With thousands
|
2023-12-05 21:56:47 +00:00
|
|
|
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) {
|
2024-10-01 18:29:14 +00:00
|
|
|
remotes := viper.GetStringSlice(FlagRemote)
|
2024-01-17 15:06:20 +00:00
|
|
|
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
|
|
|
}
|