Added historical data option

This commit is contained in:
Andrew Scott 2022-08-02 23:26:09 -04:00
parent cdf1cb0971
commit e74d4fe74f
Signed by: a
GPG key ID: 3EB62D0BBB8DB381

View file

@ -8,7 +8,7 @@ import (
"strings" "strings"
) )
func advancedMenu(app *application) { func advancedMenu(app *Application) {
var option string var option string
@ -19,6 +19,7 @@ func advancedMenu(app *application) {
fmt.Printf("1. Change units (Default: imperial; Current: %s)\n", app.Config.Units) fmt.Printf("1. Change units (Default: imperial; Current: %s)\n", app.Config.Units)
fmt.Println("2. Enter precise location") fmt.Println("2. Enter precise location")
fmt.Println("3. Get historical data")
fmt.Print("0. Back\n\n") fmt.Print("0. Back\n\n")
// Read user input // Read user input
@ -27,7 +28,6 @@ func advancedMenu(app *application) {
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
option = strings.TrimSuffix(input, "\n") option = strings.TrimSuffix(input, "\n")
// Check user input // Check user input
@ -54,7 +54,22 @@ func advancedMenu(app *application) {
fmt.Println("Are you sure the coordinates are valid?") fmt.Println("Are you sure the coordinates are valid?")
} }
} }
printWeather(app)
app.Forecast.Main.Temp = 0.00
} else if option == "3" {
var validLoc bool
for !validLoc {
getPreciseLocation(app)
getHistorical(app.Client)
}
if app.Forecast.Main.Temp != 0.00 {
validLoc = true
} else {
fmt.Println("I couldn't get any information for that location.")
fmt.Println("Are you sure the coordinates are valid?")
}
printWeather(app) printWeather(app)
app.Forecast.Main.Temp = 0.00 app.Forecast.Main.Temp = 0.00
} }