package cli import ( "database/sql" "fmt" "sevenkeys/database" "sevenkeys/logic" ) var ( selectedCardPrintingId string selectedCardPrintingSearchLine string storageBoxLabel string source string cardCondition string ) func ShowStorageInfo() { fmt.Println("Storage location:", storageBoxLabel, "|", "Source:", source) if selectedCardPrintingId != "" { fmt.Println("Selected card:", selectedCardPrintingSearchLine) } } func GetStorageOptions() { storageBoxLabel = GetStringResponse("Storage box label:") source = GetStringResponse("Card source:") cardCondition = GetStringResponse("Card condition:") } func InsertSelectedCard(db *sql.DB) { if selectedCardPrintingId == "" { fmt.Println("No card selected, please [search] for a card printing.") return } if storageBoxLabel == "" { GetStorageOptions() } storageLocation := database.CardStorageLocation{ CardPrintingId: selectedCardPrintingId, StorageBox: storageBoxLabel, Source: source, } logic.StoreCard(db, storageLocation) } func StashCliLoop(db *sql.DB, searchOptions logic.SearchOptions) { var command string for { ShowStorageInfo() command = GetStringResponse("SEVENKEYS (stash) $") switch command { case "back": return case "storage": GetStorageOptions() break case "search": var err error selectedCardPrintingId, selectedCardPrintingSearchLine, err = logic.Search(searchOptions) logic.Check(err) break case "insert": InsertSelectedCard(db) break default: fmt.Println("Unrecognized command:", command) break } } }