2024-09-24 06:17:11 -04:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2024-11-15 02:02:45 -05:00
|
|
|
"github.com/nitezs/pcgamedb/db"
|
|
|
|
"github.com/nitezs/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.GetUnorganizedGameDownloads(-1)
|
|
|
|
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),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|