Package subcommand code

This commit is contained in:
2024-12-30 14:54:32 -05:00
parent 888ee5ea4a
commit 96378d047e
19 changed files with 564 additions and 412 deletions

32
cmd/cache/cache_dump.go vendored Normal file
View File

@@ -0,0 +1,32 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
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(FlagRemote)
if conf.Dump.Full {
fmt.Println(projectCache.DumpString(true, searchStringFromArgs(args), remotes...))
} else {
plog.Info(projectCache.String())
}
}
func init() {
cacheCmd.AddCommand(dumpCmd)
dumpCmd.PersistentFlags().BoolP("full", "f", false, "Dumps entire cache")
viper.BindPFlag("dump.full", dumpCmd.LocalFlags().Lookup("full"))
}