Add confirmation menu to removing cards as well

This commit is contained in:
shylie 2025-12-22 20:10:11 -05:00
parent b58718b537
commit 6a24cd6546
3 changed files with 17 additions and 13 deletions

View File

@ -188,16 +188,3 @@ func addCards(cards []string, unique bool, count int64) error {
storageDisconnect(client)
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'
}

View File

@ -308,3 +308,16 @@ func coloredValue(value float64) string {
return outputColor
}
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'
}

View File

@ -103,6 +103,10 @@ func removeCards(cards []string, count int64) error {
continue
}
if !askConfirmation(c) {
continue
}
if foil && c.SerraCountFoil == 1 && c.SerraCount == 0 || !foil && c.SerraCount == 1 && c.SerraCountFoil == 0 {
coll.storageRemove(bson.M{"_id": c.ID})
l.Infof("\"%s\" (%.2f%s) removed", c.Name, c.getValue(foil), getCurrency())