git-project-manager/cmd/cache_dump.go

33 lines
730 B
Go
Raw Normal View History

2023-12-04 21:53:01 +00:00
package cmd
import (
"fmt"
"github.com/spf13/cobra"
2023-12-08 21:52:26 +00:00
"github.com/spf13/viper"
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-10-01 18:29:14 +00:00
remotes := viper.GetStringSlice(FlagRemote)
if conf.Dump.Full {
fmt.Println(projectCache.DumpString(true, searchStringFromArgs(args), remotes...))
} else {
plog.Info(projectCache.String())
}
2023-12-04 21:53:01 +00:00
}
func init() {
cacheCmd.AddCommand(dumpCmd)
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
}