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{
|
2023-12-29 15:24:12 +00:00
|
|
|
Use: "dump",
|
|
|
|
Short: "Dump GitLab project cache",
|
|
|
|
Long: `Dumps cache to display`,
|
|
|
|
PreRun: runCacheCmd,
|
|
|
|
PostRun: postCacheCmd,
|
2024-01-17 15:06:20 +00:00
|
|
|
Run: runCacheDunpCmd,
|
|
|
|
}
|
|
|
|
|
|
|
|
func runCacheDunpCmd(cmd *cobra.Command, args []string) {
|
|
|
|
remotes := viper.GetStringSlice("remote")
|
|
|
|
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
|
|
|
}
|