mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2025-01-02 14:25:55 -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)
|
fmt.Printf("\nChanged units from %s to %s...\n\n", current, app.Config.Units)
|
||||||
} else if option == "2" {
|
} 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)
|
printWeather(app)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue