git-project-manager/cmd/cache/cache_dump.go

34 lines
807 B
Go
Raw Normal View History

2024-12-30 20:50:31 +00:00
package cache
2023-12-04 21:53:01 +00:00
import (
"fmt"
"github.com/spf13/cobra"
2023-12-08 21:52:26 +00:00
"github.com/spf13/viper"
2024-12-30 20:50:31 +00:00
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
2023-12-04 21:53:01 +00:00
)
var dumpCmd = &cobra.Command{
Use: "dump",
2024-12-27 22:42:44 +00:00
Short: "Dump Git project cache",
Long: `Dumps cache to display`,
PreRun: runCacheCmd,
PostRun: postCacheCmd,
Run: runCacheDunpCmd,
}
func runCacheDunpCmd(cmd *cobra.Command, args []string) {
2024-12-30 20:50:31 +00:00
remotes := viper.GetStringSlice(util.FlagRemote)
if utils.Config().Dump.Full {
fmt.Println(utils.Cache().DumpString(true, utils.SearchStringFromArgs(args), remotes...))
} else {
2024-12-30 20:50:31 +00:00
utils.Logger().Info(utils.Cache().String())
}
2023-12-04 21:53:01 +00:00
}
func init() {
2023-12-08 21:52:26 +00:00
dumpCmd.PersistentFlags().BoolP("full", "f", false, "Dumps entire cache")
viper.BindPFlag("dump.full", dumpCmd.LocalFlags().Lookup("full"))
2023-12-04 21:53:01 +00:00
}