collectornumber is now a number
This commit is contained in:
parent
9ddb187eea
commit
7f88d6a6f4
8
f
Normal file
8
f
Normal file
@ -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
|
||||||
3
serra.go
3
serra.go
@ -14,6 +14,7 @@ func main() {
|
|||||||
Usage:
|
Usage:
|
||||||
serra add <card>...
|
serra add <card>...
|
||||||
serra cards
|
serra cards
|
||||||
|
serra set <set>
|
||||||
serra sets
|
serra sets
|
||||||
serra update
|
serra update
|
||||||
|
|
||||||
@ -30,6 +31,8 @@ Options:
|
|||||||
serra.Cards()
|
serra.Cards()
|
||||||
} else if args["sets"].(bool) {
|
} else if args["sets"].(bool) {
|
||||||
serra.Sets()
|
serra.Sets()
|
||||||
|
} else if args["set"].(bool) {
|
||||||
|
serra.ShowSet(args["<set>"].(string))
|
||||||
} else if args["update"].(bool) {
|
} else if args["update"].(bool) {
|
||||||
serra.Update()
|
serra.Update()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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() {
|
func Update() {
|
||||||
LogMessage(fmt.Sprintf("Serra %v\n", version), "green")
|
LogMessage(fmt.Sprintf("Serra %v\n", version), "green")
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ type Card struct {
|
|||||||
BorderColor string `json:"border_color"`
|
BorderColor string `json:"border_color"`
|
||||||
CardBackID string `json:"card_back_id"`
|
CardBackID string `json:"card_back_id"`
|
||||||
Cmc int64 `json:"cmc"`
|
Cmc int64 `json:"cmc"`
|
||||||
CollectorNumber string `json:"collector_number"`
|
CollectorNumber int64 `json:"collector_number,string"`
|
||||||
ColorIdentity []string `json:"color_identity"`
|
ColorIdentity []string `json:"color_identity"`
|
||||||
Colors []string `json:"colors"`
|
Colors []string `json:"colors"`
|
||||||
Digital bool `json:"digital"`
|
Digital bool `json:"digital"`
|
||||||
@ -156,7 +156,7 @@ func fetch_card(path string) (*Card, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
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
|
return &Card{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ func fetch_set(path string) (*Set, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
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
|
return &Set{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user