TheMathemagicians/sevenkeys/cli/storage.go

56 lines
1007 B
Go
Raw Permalink Normal View History

package cli
import (
"database/sql"
"fmt"
2024-08-20 14:28:49 +00:00
"io"
"sevenkeys/database"
"sevenkeys/logic"
)
var (
selectedCardPrintingSearchLine string
copiesInserted int
)
func getInfoDisplay(info string) string {
if info == "" {
return "[EMPTY]"
}
return info
}
2024-08-20 14:28:49 +00:00
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?
2024-08-20 14:28:49 +00:00
fmt.Fprint(w, "[None]\n")
return
}
fmt.Fprintf(w, "%s (%s)\n", area.Name, area.StorageType)
2024-08-20 14:28:49 +00:00
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++
}