diff --git a/f b/f new file mode 100644 index 0000000..7d31ae6 --- /dev/null +++ b/f @@ -0,0 +1,8 @@ +for x in (seq 1 360 ) ; echo 4ed/$x ; end | xargs ./serra add +for x in (seq 11 140 ) ; echo unh/$x ; end | xargs ./serra add +for x in (seq 1 9 ) ; echo unh/$x ; end | xargs ./serra add +./serra add tugl/1 +for x in (seq 71 89) ; echo ugl/$x ; end | xargs ./serra add +for x in (seq 1 69) ; echo ugl/$x ; end | xargs ./serra add +for x in (seq 251 350) ; echo mmq/$x ; end | xargs ./serra add +for x in (seq 4 250) ; echo mmq/$x ; end | xargs ./serra add diff --git a/serra b/serra index 35cc657..9627604 100755 Binary files a/serra and b/serra differ diff --git a/serra.go b/serra.go index e3f446b..9a65bcc 100644 --- a/serra.go +++ b/serra.go @@ -14,6 +14,7 @@ func main() { Usage: serra add ... serra cards + serra set serra sets serra update @@ -30,6 +31,8 @@ Options: serra.Cards() } else if args["sets"].(bool) { serra.Sets() + } else if args["set"].(bool) { + serra.ShowSet(args[""].(string)) } else if args["update"].(bool) { serra.Update() } diff --git a/src/serra/root.go b/src/serra/root.go index 708d49c..51ed235 100644 --- a/src/serra/root.go +++ b/src/serra/root.go @@ -88,6 +88,30 @@ func Sets() { } +func ShowSet(setname string) error { + LogMessage(fmt.Sprintf("Serra %v\n", version), "green") + + client := storage_connect() + coll := &Collection{client.Database("serra").Collection("cards")} + + sort := bson.D{{"collectornumber", 1}} + filter := bson.D{{"set", setname}} + cards, err := coll.storage_find(filter, sort) + if (err != nil) || len(cards) == 0 { + LogMessage(fmt.Sprintf("Error: Set %s not found or no card in your collection.", setname), "red") + return err + } + + // print + fmt.Printf("%s\n", cards[0].SetName) + for _, card := range cards { + fmt.Printf("%dx %d %s %.2f\n", card.SerraCount, card.CollectorNumber, card.Name, card.Prices.Eur) + } + storage_disconnect(client) + return nil + +} + func Update() { LogMessage(fmt.Sprintf("Serra %v\n", version), "green") diff --git a/src/serra/scryfall.go b/src/serra/scryfall.go index 75aa873..c964eb6 100644 --- a/src/serra/scryfall.go +++ b/src/serra/scryfall.go @@ -26,7 +26,7 @@ type Card struct { BorderColor string `json:"border_color"` CardBackID string `json:"card_back_id"` Cmc int64 `json:"cmc"` - CollectorNumber string `json:"collector_number"` + CollectorNumber int64 `json:"collector_number,string"` ColorIdentity []string `json:"color_identity"` Colors []string `json:"colors"` Digital bool `json:"digital"` @@ -156,7 +156,7 @@ func fetch_card(path string) (*Card, error) { } if resp.StatusCode != 200 { - err := errors.New(fmt.Sprintf("card: %s not found", path)) + err := errors.New(fmt.Sprintf("Error: %s not found", path)) return &Card{}, err } @@ -193,7 +193,7 @@ func fetch_set(path string) (*Set, error) { } if resp.StatusCode != 200 { - err := errors.New(fmt.Sprintf("set: %s not found", path)) + err := errors.New(fmt.Sprintf("Error: %s not found", path)) return &Set{}, err }