31 lines
691 B
Go
31 lines
691 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
var loadCmd = &cobra.Command{
|
|
Use: "load",
|
|
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,
|
|
}
|
|
|
|
func loadCache(cmd *cobra.Command, args []string) {
|
|
cache.Refresh()
|
|
}
|
|
|
|
func init() {
|
|
cacheCmd.AddCommand(loadCmd)
|
|
|
|
loadCmd.PersistentFlags().Bool("ownerOnly", true,
|
|
"Only load projects that you are owner of")
|
|
|
|
viper.BindPFlag("cache.load.ownerOnly", loadCmd.Flag("ownerOnly"))
|
|
}
|