mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-09 06:00:52 -05:00
Reset temp after checking for valid location
This commit is contained in:
parent
7d59138191
commit
13f1e5da8c
1 changed files with 5 additions and 0 deletions
|
@ -12,6 +12,7 @@ func advancedMenu(app *application) {
|
||||||
|
|
||||||
var option string
|
var option string
|
||||||
|
|
||||||
|
// Menu loop
|
||||||
for option != "0" {
|
for option != "0" {
|
||||||
|
|
||||||
fmt.Print("\nAdvanced Menu\n-------------\n\n")
|
fmt.Print("\nAdvanced Menu\n-------------\n\n")
|
||||||
|
@ -20,6 +21,7 @@ func advancedMenu(app *application) {
|
||||||
fmt.Println("2. Enter precise location")
|
fmt.Println("2. Enter precise location")
|
||||||
fmt.Print("0. Back\n\n")
|
fmt.Print("0. Back\n\n")
|
||||||
|
|
||||||
|
// Read user input
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
input, err := reader.ReadString('\n')
|
input, err := reader.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -28,6 +30,7 @@ func advancedMenu(app *application) {
|
||||||
|
|
||||||
option = strings.TrimSuffix(input, "\n")
|
option = strings.TrimSuffix(input, "\n")
|
||||||
|
|
||||||
|
// Check user input
|
||||||
if option == "1" {
|
if option == "1" {
|
||||||
current := app.Config.Units
|
current := app.Config.Units
|
||||||
if current == "imperial" {
|
if current == "imperial" {
|
||||||
|
@ -38,6 +41,7 @@ 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" {
|
||||||
|
|
||||||
|
// Loop to validate location entered
|
||||||
var validLoc bool
|
var validLoc bool
|
||||||
for !validLoc {
|
for !validLoc {
|
||||||
getPreciseLocation(app)
|
getPreciseLocation(app)
|
||||||
|
@ -52,6 +56,7 @@ func advancedMenu(app *application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
printWeather(app)
|
printWeather(app)
|
||||||
|
app.Forecast.Main.Temp = 0.00
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue