From eb46a898cc3665fca8ea2f93d4052b225f64e46b Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Tue, 28 Nov 2023 19:00:00 +0100 Subject: [PATCH] add color identity to search --- src/serra/card.go | 7 +++++++ src/serra/root.go | 1 + 2 files changed, 8 insertions(+) diff --git a/src/serra/card.go b/src/serra/card.go index 7160131..f4b11a2 100644 --- a/src/serra/card.go +++ b/src/serra/card.go @@ -14,6 +14,7 @@ func init() { cardCmd.Flags().StringVarP(&set, "set", "e", "", "Filter by set code (usg/mmq/vow)") cardCmd.Flags().StringVarP(&sortby, "sort", "s", "name", "How to sort cards (value/number/name/added)") cardCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the card (regex compatible)") + cardCmd.Flags().StringVarP(&color, "color", "i", "", "Color identity of card (w,u,b,r,g)") cardCmd.Flags().StringVarP(&oracle, "oracle", "o", "", "Contains string in card text") cardCmd.Flags().StringVarP(&cardType, "type", "t", "", "Contains string in card type line") cardCmd.Flags().Int64VarP(&count, "min-count", "c", 0, "Occource more than X in your collection") @@ -112,6 +113,12 @@ func Cards(rarity, set, sortby, name, oracle, cardType string, reserved, foil bo filter = append(filter, bson.E{"typeline", bson.D{{"$regex", ".*" + cardType + ".*"}, {"$options", "i"}}}) } + if len(color) > 0 { + colorArr := strings.Split(strings.ToUpper(color), ",") + fmt.Println(colorArr) + filter = append(filter, bson.E{"coloridentity", colorArr}) + } + if reserved { filter = append(filter, bson.E{"reserved", true}) } diff --git a/src/serra/root.go b/src/serra/root.go index dc6ba8e..b9f751c 100644 --- a/src/serra/root.go +++ b/src/serra/root.go @@ -8,6 +8,7 @@ var ( Version = "unknown" address string cardType string + color string count int64 detail bool foil bool