pcgamedb/cmd/list.go

45 lines
841 B
Go
Raw Permalink Normal View History

2024-09-24 06:17:11 -04:00
package cmd
import (
2024-11-20 06:09:04 -05:00
"pcgamedb/db"
"pcgamedb/log"
2024-09-24 06:17:11 -04:00
"github.com/spf13/cobra"
"go.uber.org/zap"
)
var listCmd = &cobra.Command{
Use: "list",
Long: "List game infos by filter",
Short: "List game infos by filter",
Run: listRun,
}
type listCommandConfig struct {
Unid bool
}
var listCmdCfg listCommandConfig
func init() {
listCmd.Flags().BoolVarP(&listCmdCfg.Unid, "unorganized", "u", false, "unorganized")
RootCmd.AddCommand(listCmd)
}
func listRun(cmd *cobra.Command, args []string) {
if listCmdCfg.Unid {
games, err := db.GetUnorganizedGameItems(-1)
2024-09-24 06:17:11 -04:00
if err != nil {
log.Logger.Error("Failed to get games", zap.Error(err))
}
for _, game := range games {
log.Logger.Info(
"Game",
zap.Any("game_id", game.ID),
zap.String("raw_name", game.RawName),
zap.String("name", game.Name),
)
}
}
}