coloring
This commit is contained in:
parent
b92df9130d
commit
bc1be395cd
12
serra.go
12
serra.go
@ -19,7 +19,8 @@ var opts struct {
|
|||||||
Sets bool `docopt:"sets"`
|
Sets bool `docopt:"sets"`
|
||||||
Stats bool `docopt:"stats"`
|
Stats bool `docopt:"stats"`
|
||||||
Missing bool `docopt:"missing"`
|
Missing bool `docopt:"missing"`
|
||||||
Raising bool `docopt:"raising"`
|
Tops bool `docopt:"tops"`
|
||||||
|
Flops bool `docopt:"flops"`
|
||||||
Update bool `docopt:"update"`
|
Update bool `docopt:"update"`
|
||||||
CardId []string `docopt:"<cardid>"`
|
CardId []string `docopt:"<cardid>"`
|
||||||
SetCode string `docopt:"<setcode>,--set"`
|
SetCode string `docopt:"<setcode>,--set"`
|
||||||
@ -39,7 +40,8 @@ Usage:
|
|||||||
serra remove <cardid>...
|
serra remove <cardid>...
|
||||||
serra cards [--rarity=<rarity>] [--set=<setcode>] [--sort=<sort>]
|
serra cards [--rarity=<rarity>] [--set=<setcode>] [--sort=<sort>]
|
||||||
serra card <cardid>...
|
serra card <cardid>...
|
||||||
serra raising [--limit=<limit>]
|
serra tops [--limit=<limit>]
|
||||||
|
serra flops [--limit=<limit>]
|
||||||
serra missing <setcode>
|
serra missing <setcode>
|
||||||
serra set <setcode>
|
serra set <setcode>
|
||||||
serra sets
|
serra sets
|
||||||
@ -71,8 +73,10 @@ Options:
|
|||||||
serra.Sets()
|
serra.Sets()
|
||||||
} else if opts.Missing {
|
} else if opts.Missing {
|
||||||
serra.Missing(opts.SetCode)
|
serra.Missing(opts.SetCode)
|
||||||
} else if opts.Raising {
|
} else if opts.Tops {
|
||||||
serra.Raising(opts.Limit)
|
serra.Gains(opts.Limit, -1)
|
||||||
|
} else if opts.Flops {
|
||||||
|
serra.Gains(opts.Limit, 1)
|
||||||
} else if opts.Set {
|
} else if opts.Set {
|
||||||
serra.ShowSet(opts.SetCode)
|
serra.ShowSet(opts.SetCode)
|
||||||
} else if opts.Update {
|
} else if opts.Update {
|
||||||
|
|||||||
@ -398,7 +398,7 @@ func Update() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Raising(limit float64) error {
|
func Gains(limit float64, sort int) error {
|
||||||
|
|
||||||
client := storage_connect()
|
client := storage_connect()
|
||||||
coll := &Collection{client.Database("serra").Collection("cards")}
|
coll := &Collection{client.Database("serra").Collection("cards")}
|
||||||
@ -450,12 +450,22 @@ func Raising(limit float64) error {
|
|||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
bson.D{{"$sort",
|
bson.D{{"$sort",
|
||||||
bson.D{{"rate", -1}}}},
|
bson.D{{"rate", sort}}}},
|
||||||
bson.D{{"$limit", 20}},
|
bson.D{{"$limit", 20}},
|
||||||
}
|
}
|
||||||
raise, _ := coll.storage_aggregate(raise_pipeline)
|
raise, _ := coll.storage_aggregate(raise_pipeline)
|
||||||
|
|
||||||
|
// percentage coloring
|
||||||
|
var p_color string
|
||||||
|
if sort == 1 {
|
||||||
|
p_color = Red
|
||||||
|
} else {
|
||||||
|
p_color = Green
|
||||||
|
}
|
||||||
|
|
||||||
|
// print each card
|
||||||
for _, e := range raise {
|
for _, e := range raise {
|
||||||
fmt.Printf("%s%+.0f%%%s %s%s%s %s(%s/%s)%s (%.2f->%s%.2f EUR%s) \n", Green, e["rate"], Reset, Pink, e["name"], Reset, Yellow, e["set"], e["collectornumber"], Reset, e["old"], Green, e["current"], Reset)
|
fmt.Printf("%s%+.0f%%%s %s %s(%s/%s)%s (%.2f->%s%.2f EUR%s) \n", p_color, e["rate"], Reset, e["name"], Yellow, e["set"], e["collectornumber"], Reset, e["old"], Green, e["current"], Reset)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user