TheMathemagicians/sevenkeys/cli/storage.go

56 lines
1007 B
Go

package cli
import (
"database/sql"
"fmt"
"io"
"sevenkeys/database"
"sevenkeys/logic"
)
var (
selectedCardPrintingSearchLine string
copiesInserted int
)
func getInfoDisplay(info string) string {
if info == "" {
return "[EMPTY]"
}
return info
}
func showStorageInfo(w io.Writer, area database.StorageArea) {
fmt.Fprint(w, "Selected Storage Area: ")
if area.Name == "" { // TODO: Add a struct method to determine whether it is unset?
fmt.Fprint(w, "[None]\n")
return
}
fmt.Fprintf(w, "%s (%s)\n", area.Name, area.StorageType)
return
}
func showCopiesInserted() {
fmt.Println("Copies inserted:", copiesInserted)
}
func insertSelectedCard(db *sql.DB, area database.StorageArea, location database.CardLocation) {
if area.Name == "" {
output = "No storage area selected."
return
}
if location.CardPrintingId == "" {
output = "No card selected, please [search] for a card printing."
return
}
err := logic.StoreCard(db, location)
logic.Check(err)
copiesInserted++
}