TheMathemagicians/sevenkeys/cli/storage.go

59 lines
1.3 KiB
Go

package cli
import (
"database/sql"
"fmt"
"sevenkeys/database"
"sevenkeys/logic"
)
var (
cardStorageLocation database.CardStorageLocation
selectedCardPrintingSearchLine string
copiesInserted int
)
func getInfoDisplay(info string) string {
if info == "" {
return "[EMPTY]"
}
return info
}
func showStorageInfo() {
fmt.Println("STORAGE SETTINGS")
storageBoxDisplay := getInfoDisplay(cardStorageLocation.StorageBox)
sourceDisplay := getInfoDisplay(cardStorageLocation.Source)
conditionDisplay := getInfoDisplay(cardStorageLocation.CardCondition)
fmt.Println("Storage location:", storageBoxDisplay)
fmt.Println("Source:", sourceDisplay)
fmt.Println("Condition:", conditionDisplay)
fmt.Print("\n")
}
func showCopiesInserted() {
fmt.Println("Copies inserted:", copiesInserted)
}
func insertSelectedCard(db *sql.DB) {
if cardStorageLocation.CardPrintingId == "" {
output = "No card selected, please [search] for a card printing."
return
}
if cardStorageLocation.StorageBox == "" || cardStorageLocation.CardCondition == "" {
cardStorageLocation.StorageBox = GetStringResponse("Storage location:")
cardStorageLocation.CardCondition = GetStringResponse("Card condition:")
}
err := logic.StoreCard(db, cardStorageLocation)
logic.Check(err)
copiesInserted++
}