Allow the user to quit properly

This commit is contained in:
The Magician 2024-05-31 22:44:52 +01:00
parent 4018f26998
commit 7dba7e4649
2 changed files with 9 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package logic
import ( import (
"database/sql" "database/sql"
"log"
"sevenkeys/database" "sevenkeys/database"
) )
@ -12,6 +13,7 @@ func StoreCard(db *sql.DB, storageLocation database.CardStorageLocation) error {
} }
storageLocation.Position = lastPosition + 1 storageLocation.Position = lastPosition + 1
log.Println(storageLocation.Position)
err = database.InsertCardStorageLocation(db, storageLocation) err = database.InsertCardStorageLocation(db, storageLocation)
if err != nil { if err != nil {

View File

@ -2,11 +2,10 @@ package main
import ( import (
"fmt" "fmt"
"os"
"sevenkeys/database" "sevenkeys/database"
"sevenkeys/logic" "sevenkeys/logic"
"sevenkeys/logic/scryfall" "sevenkeys/logic/scryfall"
"github.com/inancgumus/screen"
) )
func main() { func main() {
@ -45,8 +44,10 @@ func main() {
logic.Check(err) logic.Check(err)
for { for {
screen.Clear() /*
screen.MoveTopLeft() screen.Clear()
screen.MoveTopLeft()
*/
fmt.Println("Storage location:", storageBox) fmt.Println("Storage location:", storageBox)
fmt.Println("Source:", source) fmt.Println("Source:", source)
@ -69,8 +70,9 @@ func main() {
case "r": case "r":
err = logic.StoreCard(db, storageLocation) err = logic.StoreCard(db, storageLocation)
logic.Check(err) logic.Check(err)
case "q":
break break
case "q":
os.Exit(0)
} }
} }
} }