38 lines
703 B
Go
38 lines
703 B
Go
package cli
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"sevenkeys/logic"
|
|
"sevenkeys/logic/scryfall"
|
|
)
|
|
|
|
func RunUpdateCheck(db *sql.DB) {
|
|
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("No update required.")
|
|
return
|
|
}
|
|
|
|
fmt.Println("Update required.")
|
|
if GetYesNoResponse("Run update? (y/N)") {
|
|
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.")
|
|
}
|