From c5b8ad727038f2b8471c5f38d4131798b13d1229 Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Wed, 8 Nov 2023 14:44:41 +0100 Subject: [PATCH] Add shortcuts to interactive add mode --- src/serra/add.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/serra/add.go b/src/serra/add.go index 0c17ae9..dcadfc0 100644 --- a/src/serra/add.go +++ b/src/serra/add.go @@ -72,7 +72,23 @@ func addCardsInteractive(unique bool, set string) { } } } else { - card = append(card, fmt.Sprintf("%s/%s", set, strings.TrimSpace(line))) + card = append(card, fmt.Sprintf("%s/%s", set, strings.Split(line, " ")[0])) + } + + // Are there extra arguments? + if len(strings.Split(line, " ")) == 2 { + + // foil shortcut + if strings.Split(line, " ")[1] == "f" { + foil = true + } + + // amount shortcut + if amount, err := strconv.Atoi(strings.Split(line, " ")[1]); err == nil { + if amount > 1 { + count = int64(amount) + } + } } addCards(card, unique, count) @@ -144,7 +160,11 @@ func addCards(cards []string, unique bool, count int64) error { } // Give feedback of successfully added card - l.Infof("%dx \"%s\" (%s, %.2f%s) added", total, c.Name, c.Rarity, c.getValue(foil), getCurrency()) + if foil { + l.Infof("%dx \"%s\" (%s, %.2f%s, foil) added", total, c.Name, c.Rarity, c.getValue(foil), getCurrency()) + } else { + l.Infof("%dx \"%s\" (%s, %.2f%s) added", total, c.Name, c.Rarity, c.getValue(foil), getCurrency()) + } } } storageDisconnect(client)