32 lines
816 B
Go
32 lines
816 B
Go
package cache
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
|
|
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
|
)
|
|
|
|
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(util.FlagRemote)
|
|
utils.Cache().Refresh(remotes...)
|
|
}
|
|
|
|
func init() {
|
|
loadCmd.PersistentFlags().Bool(util.FlagOwnerOnly, true,
|
|
"Only load projects that you are owner of")
|
|
|
|
viper.BindPFlag(util.ViperCacheLoadOwnerOnly, loadCmd.Flag(util.FlagOwnerOnly))
|
|
}
|