mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-08 05:50:51 -05:00
Implemented unit switching, added location menu
This commit is contained in:
parent
7f08573637
commit
12012b54a6
1 changed files with 10 additions and 11 deletions
|
@ -6,10 +6,9 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func advancedMenu(wg *sync.WaitGroup, cfg *config) {
|
||||
func advancedMenu(app *application) {
|
||||
|
||||
var option string
|
||||
|
||||
|
@ -17,29 +16,29 @@ func advancedMenu(wg *sync.WaitGroup, cfg *config) {
|
|||
|
||||
fmt.Print("\nAdvanced Menu\n-------------\n\n")
|
||||
|
||||
fmt.Println("1. Change units (Default: Fahrenheit)")
|
||||
fmt.Println("1. Change units (Default: Imperial)")
|
||||
fmt.Println("2. Enter precise location")
|
||||
fmt.Print("0. Back\n\n")
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
input, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
option = strings.TrimSuffix(input, "\n")
|
||||
|
||||
if option == "1" {
|
||||
current := cfg.Units
|
||||
if current == "F" {
|
||||
cfg.Units = "C"
|
||||
current := app.Config.Units
|
||||
if current == "imperial" {
|
||||
app.Config.Units = "metric"
|
||||
} else {
|
||||
cfg.Units = "F"
|
||||
app.Config.Units = "imperial"
|
||||
}
|
||||
fmt.Printf("\nChanged units from %s to %s...\n\n", current, cfg.Units)
|
||||
fmt.Printf("\nChanged units from %s to %s...\n\n", current, app.Config.Units)
|
||||
} else if option == "2" {
|
||||
fmt.Print("Precise location selected...\n\n")
|
||||
getPreciseLocation(app)
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
app.WaitGroup.Done()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue