Package subcommand code
This commit is contained in:
31
cmd/cache/cache_load.go
vendored
Normal file
31
cmd/cache/cache_load.go
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var loadCmd = &cobra.Command{
|
||||
Use: "load",
|
||||
Short: "Load Git Project Cache",
|
||||
Long: `Used to initialize or update a new Git 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) {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
projectCache.Refresh(remotes...)
|
||||
}
|
||||
|
||||
func init() {
|
||||
cacheCmd.AddCommand(loadCmd)
|
||||
|
||||
loadCmd.PersistentFlags().Bool(FlagOwnerOnly, true,
|
||||
"Only load projects that you are owner of")
|
||||
|
||||
viper.BindPFlag(ViperCacheLoadOwnerOnly, loadCmd.Flag(FlagOwnerOnly))
|
||||
}
|
||||
Reference in New Issue
Block a user