package main import ( "fmt" "os" "sevenkeys/database" "sevenkeys/logic" "sevenkeys/logic/scryfall" ) func main() { db := database.GetDatabaseFromConfig("config.json") fmt.Println("Checking for updates...") bulkData, err := scryfall.GetBulkDataByType(scryfall.BulkDataTypeAllCards) logic.Check(err) needsUpdate, err := logic.CheckForUpdates(db, bulkData) logic.Check(err) if needsUpdate { fmt.Println("Update required.") if logic.ConfirmUpdate() { fmt.Println("Running update...") logic.CreateCacheDirectories() err = logic.UpdateSets(db) logic.Check(err) err = logic.UpdateCards(db, bulkData) logic.Check(err) } fmt.Println("Update finished.") } else { fmt.Println("No update required.") } storageBox := logic.GetResponse("Enter storage box label:") source := logic.GetResponse("Enter source:") searchOptions, err := logic.GetAllSearchOptions(db) logic.Check(err) for { /* screen.Clear() screen.MoveTopLeft() */ fmt.Println("Storage location:", storageBox) fmt.Println("Source:", source) selectedCardPrintingId, selectedSearchOption, err := logic.Search(searchOptions) logic.Check(err) fmt.Println("Inserted card:", selectedSearchOption) storageLocation := database.CardStorageLocation{ CardPrintingId: selectedCardPrintingId, StorageBox: storageBox, Source: source, } err = logic.StoreCard(db, storageLocation) logic.Check(err) nextAction := logic.GetResponse("[s]earch again/[r]epeat last insert/[q]uit:") switch nextAction { case "s": continue case "r": err = logic.StoreCard(db, storageLocation) logic.Check(err) break case "q": os.Exit(0) } } }