Implemented unit switching, added location menu

This commit is contained in:
Andrew Scott 2022-07-08 22:12:39 -04:00
parent 7f08573637
commit 12012b54a6
Signed by: a
GPG key ID: 3EB62D0BBB8DB381

View file

@ -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()
}