TheMathemagicians/sevenkeys/main.go

49 lines
872 B
Go
Raw Normal View History

2024-05-28 14:29:13 +00:00
package main
import (
"fmt"
"sevenkeys/database"
"sevenkeys/logic"
2024-05-29 19:55:38 +00:00
"sevenkeys/logic/scryfall"
2024-05-30 14:19:18 +00:00
"github.com/inancgumus/screen"
2024-05-28 14:29:13 +00:00
)
func main() {
db := database.GetDatabaseFromConfig("config.json")
2024-05-28 14:38:30 +00:00
fmt.Println("Checking for updates...")
2024-05-29 19:55:38 +00:00
bulkData, err := scryfall.GetBulkDataByType(scryfall.BulkDataTypeAllCards)
logic.Check(err)
needsUpdate, err := logic.CheckForUpdates(db, bulkData)
2024-05-28 14:29:13 +00:00
logic.Check(err)
if needsUpdate {
2024-05-28 14:38:30 +00:00
fmt.Println("Update required.")
2024-05-29 19:55:38 +00:00
2024-05-28 14:38:30 +00:00
if logic.ConfirmUpdate() {
2024-05-29 19:55:38 +00:00
fmt.Println("Running update...")
logic.CreateCacheDirectories()
err = logic.UpdateSets(db)
logic.Check(err)
err = logic.UpdateCards(db, bulkData)
logic.Check(err)
2024-05-28 14:38:30 +00:00
}
2024-05-29 19:55:38 +00:00
fmt.Println("Update finished.")
} else {
fmt.Println("No update required.")
2024-05-28 14:29:13 +00:00
}
2024-05-30 13:32:04 +00:00
2024-05-30 14:19:18 +00:00
//storageLocation := logic.GetStorageLocation()
2024-05-30 13:32:04 +00:00
for {
2024-05-30 14:19:18 +00:00
screen.Clear()
screen.MoveTopLeft()
2024-05-30 13:32:04 +00:00
}
2024-05-28 14:29:13 +00:00
}