mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-08 05:50:51 -05:00
Added basic validation for location input
This commit is contained in:
parent
9296d7a629
commit
403cb21b51
1 changed files with 14 additions and 2 deletions
|
@ -37,8 +37,20 @@ func advancedMenu(app *application) {
|
|||
}
|
||||
fmt.Printf("\nChanged units from %s to %s...\n\n", current, app.Config.Units)
|
||||
} else if option == "2" {
|
||||
getPreciseLocation(app)
|
||||
getCurrent(app)
|
||||
|
||||
var validLoc bool
|
||||
for !validLoc {
|
||||
getPreciseLocation(app)
|
||||
getCurrent(app)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue