mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-08 05:50:51 -05:00
Added historical data option
This commit is contained in:
parent
cdf1cb0971
commit
e74d4fe74f
1 changed files with 17 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue