TheMathemagicians/sevenkeys/main.go

40 lines
738 B
Go

package main
import (
"fmt"
"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.")
}
}