rename sort to sortby

This commit is contained in:
Florian Baumann 2023-03-01 13:53:28 +01:00
parent 7a24cecd93
commit be949a0174
3 changed files with 7 additions and 7 deletions

View File

@ -11,7 +11,7 @@ import (
func init() { func init() {
cardCmd.Flags().StringVarP(&rarity, "rarity", "r", "", "Filter by rarity of cards (mythic, rare, uncommon, common)") cardCmd.Flags().StringVarP(&rarity, "rarity", "r", "", "Filter by rarity of cards (mythic, rare, uncommon, common)")
cardCmd.Flags().StringVarP(&set, "set", "e", "", "Filter by set code (usg/mmq/vow)") cardCmd.Flags().StringVarP(&set, "set", "e", "", "Filter by set code (usg/mmq/vow)")
cardCmd.Flags().StringVarP(&sort, "sort", "s", "name", "How to sort cards (value/number/name/added)") 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(&name, "name", "n", "", "Name of the card (regex compatible)")
cardCmd.Flags().StringVarP(&oracle, "oracle", "o", "", "Contains string in card text") 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().StringVarP(&cardType, "type", "t", "", "Contains string in card type line")
@ -28,7 +28,7 @@ otherwise you'll get a list of cards as a search result.`,
SilenceErrors: true, SilenceErrors: true,
RunE: func(cmd *cobra.Command, cards []string) error { RunE: func(cmd *cobra.Command, cards []string) error {
if len(cards) == 0 { if len(cards) == 0 {
card_list := Cards(rarity, set, sort, name, oracle, cardType) card_list := Cards(rarity, set, sortby, name, oracle, cardType)
show_card_list(card_list) show_card_list(card_list)
} else { } else {
ShowCard(cards) ShowCard(cards)
@ -53,7 +53,7 @@ func ShowCard(cardids []string) {
} }
} }
func Cards(rarity, set, sort, name, oracle, cardType string) []Card { func Cards(rarity, set, sortby, name, oracle, cardType string) []Card {
client := storage_connect() client := storage_connect()
coll := &Collection{client.Database("serra").Collection("cards")} coll := &Collection{client.Database("serra").Collection("cards")}
@ -71,7 +71,7 @@ func Cards(rarity, set, sort, name, oracle, cardType string) []Card {
} }
var sortStage bson.D var sortStage bson.D
switch sort { switch sortby {
case "value": case "value":
if getCurrency() == "EUR" { if getCurrency() == "EUR" {
sortStage = bson.D{{"prices.eur", 1}} sortStage = bson.D{{"prices.eur", 1}}

View File

@ -17,7 +17,7 @@ var oracle string
var rarity string var rarity string
var set string var set string
var since string var since string
var sort string var sortby string
var cardType string var cardType string
var unique bool var unique bool

View File

@ -10,7 +10,7 @@ import (
) )
func init() { func init() {
setCmd.Flags().StringVarP(&sort, "sort", "s", "release", "How to sort cards (release/value)") setCmd.Flags().StringVarP(&sortby, "sort", "s", "release", "How to sort cards (release/value)")
rootCmd.AddCommand(setCmd) rootCmd.AddCommand(setCmd)
} }
@ -24,7 +24,7 @@ otherwise you'll get a list of sets as a search result.`,
SilenceErrors: true, SilenceErrors: true,
RunE: func(cmd *cobra.Command, set []string) error { RunE: func(cmd *cobra.Command, set []string) error {
if len(set) == 0 { if len(set) == 0 {
setList := Sets(sort) setList := Sets(sortby)
show_set_list(setList) show_set_list(setList)
} else { } else {
ShowSet(set[0]) ShowSet(set[0])