Ask user if update should be performed
This commit is contained in:
parent
8b7ec980f4
commit
708bfdf90b
|
@ -2,8 +2,10 @@ package logic
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"sevenkeys/database"
|
||||
"sevenkeys/logic/scryfall"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -30,3 +32,11 @@ func CheckForUpdates(db *sql.DB) (bool, error) {
|
|||
|
||||
return bulkCardsUpdatedTimestamp.After(cachedFileTimestamp), nil
|
||||
}
|
||||
|
||||
func ConfirmUpdate() bool {
|
||||
fmt.Print("Run update? (y/N) ")
|
||||
var response string
|
||||
fmt.Scan(&response)
|
||||
|
||||
return strings.ToUpper(response) == "Y"
|
||||
}
|
|
@ -9,16 +9,18 @@ import (
|
|||
func main() {
|
||||
db := database.GetDatabaseFromConfig("config.json")
|
||||
|
||||
fmt.Println("Checking for updates...")
|
||||
needsUpdate, err := logic.CheckForUpdates(db)
|
||||
logic.Check(err)
|
||||
|
||||
if needsUpdate {
|
||||
fmt.Println("Needs update")
|
||||
/*
|
||||
if logic.AskForScryfallUpdate() {
|
||||
fmt.Println("Update required.")
|
||||
if logic.ConfirmUpdate() {
|
||||
fmt.Println("User authorized update")
|
||||
/*
|
||||
err = logic.RunScryfallUpdate()
|
||||
logic.Check(err)
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue