diff --git a/cmd/advanced.go b/cmd/advanced.go index abc4b35..5840590 100644 --- a/cmd/advanced.go +++ b/cmd/advanced.go @@ -8,7 +8,7 @@ import ( "strings" ) -func advancedMenu(app *application) { +func advancedMenu(app *Application) { 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.Println("2. Enter precise location") + fmt.Println("3. Get historical data") fmt.Print("0. Back\n\n") // Read user input @@ -27,7 +28,6 @@ func advancedMenu(app *application) { if err != nil { log.Println(err) } - option = strings.TrimSuffix(input, "\n") // Check user input @@ -54,7 +54,22 @@ func advancedMenu(app *application) { 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) app.Forecast.Main.Temp = 0.00 }