34 lines
807 B
Go
34 lines
807 B
Go
package cache
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
|
|
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
|
)
|
|
|
|
var dumpCmd = &cobra.Command{
|
|
Use: "dump",
|
|
Short: "Dump Git project cache",
|
|
Long: `Dumps cache to display`,
|
|
PreRun: runCacheCmd,
|
|
PostRun: postCacheCmd,
|
|
Run: runCacheDunpCmd,
|
|
}
|
|
|
|
func runCacheDunpCmd(cmd *cobra.Command, args []string) {
|
|
remotes := viper.GetStringSlice(util.FlagRemote)
|
|
if utils.Config().Dump.Full {
|
|
fmt.Println(utils.Cache().DumpString(true, utils.SearchStringFromArgs(args), remotes...))
|
|
} else {
|
|
utils.Logger().Info(utils.Cache().String())
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
dumpCmd.PersistentFlags().BoolP("full", "f", false, "Dumps entire cache")
|
|
viper.BindPFlag("dump.full", dumpCmd.LocalFlags().Lookup("full"))
|
|
}
|