Adding cards now requires confirmation

This commit is contained in:
shylie 2025-12-21 11:02:09 -05:00
parent c4b4967777
commit b58718b537

View File

@ -141,11 +141,14 @@ func addCards(cards []string, unique bool, count int64) error {
continue continue
} }
if askConfirmation(&c) {
modifyCardCount(coll, &c, count, foil) modifyCardCount(coll, &c, count, foil)
}
} else { } else {
// Fetch card from scryfall // Fetch card from scryfall
c, err := fetchCard(setName, collectorNumber) c, err := fetchCard(setName, collectorNumber)
outputColor := coloredValue(c.getValue(foil)) outputColor := coloredValue(c.getValue(foil))
if err != nil { if err != nil {
l.Warn(err) l.Warn(err)
@ -163,6 +166,11 @@ func addCards(cards []string, unique bool, count int64) error {
c.SerraCountDeck = 0 c.SerraCountDeck = 0
total = c.SerraCount total = c.SerraCount
} }
if !askConfirmation(c) {
continue
}
err = coll.storageAdd(c) err = coll.storageAdd(c)
if err != nil { if err != nil {
l.Warn(err) l.Warn(err)
@ -180,3 +188,16 @@ func addCards(cards []string, unique bool, count int64) error {
storageDisconnect(client) storageDisconnect(client)
return nil return nil
} }
func askConfirmation(card *Card) bool {
drawImage(card)
fmt.Println("Is this correct (y/n)?")
var char = 'x'
for char != 'y' && char != 'n' {
fmt.Scanf("%c\n", &char)
}
return char == 'y'
}