mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-09 06:00:52 -05:00
45 lines
806 B
Go
45 lines
806 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
"sync"
|
|
)
|
|
|
|
func advancedMenu(wg *sync.WaitGroup, cfg *config) {
|
|
|
|
var option string
|
|
|
|
for option != "0" {
|
|
|
|
fmt.Print("\nAdvanced Menu\n-------------\n\n")
|
|
|
|
fmt.Println("1. Change units (Default: Fahrenheit)")
|
|
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)
|
|
}
|
|
|
|
option = strings.TrimSuffix(input, "\n")
|
|
|
|
if option == "1" {
|
|
current := cfg.Units
|
|
if current == "F" {
|
|
cfg.Units = "C"
|
|
} else {
|
|
cfg.Units = "F"
|
|
}
|
|
fmt.Printf("\nChanged units from %s to %s...\n\n", current, cfg.Units)
|
|
} else if option == "2" {
|
|
fmt.Print("Precise location selected...\n\n")
|
|
}
|
|
}
|
|
wg.Done()
|
|
}
|