Improve UI

This commit is contained in:
The Magician 2024-06-01 22:54:15 +01:00
parent a5934a1d9f
commit 1ab69e8980
1 changed files with 14 additions and 8 deletions

View File

@ -6,6 +6,8 @@ import (
"sevenkeys/database"
"sevenkeys/logic"
"sevenkeys/logic/scryfall"
"github.com/inancgumus/screen"
)
func main() {
@ -51,15 +53,18 @@ func main() {
var selectedCardId int
var selectedCardSearchOption string = "None"
var lastOutput string
for {
/*
screen.Clear()
screen.MoveTopLeft()
*/
screen.Clear()
screen.MoveTopLeft()
fmt.Println("Storage location:", storageBox, "|", "Source:", source)
fmt.Println("Selected card:", selectedCardSearchOption, "ID:", selectedCardId)
if lastOutput != "" {
fmt.Println(lastOutput)
}
var action string
action = logic.GetResponse("[s]earch for card/[i]nsert selected card/[q]uit:")
switch action {
@ -68,25 +73,26 @@ func main() {
logic.Check(err)
storageLocation.CardPrintingId = selectedCardId
lastOutput = ""
continue
case "i":
if selectedCardId == 0 {
fmt.Println("No selected card, please search for one.")
lastOutput = "No selected card, please search for one."
continue
}
err = logic.StoreCard(db, storageLocation)
logic.Check(err)
lastOutput = "Inserted card: " + selectedCardSearchOption
break
case "q":
os.Exit(0)
default:
fmt.Println("Not a valid command:", action)
lastOutput = "Not a valid command: " + action
break
}
fmt.Print("\n\n")
}
}