mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-12 06:30:49 -05:00
44 lines
819 B
Go
44 lines
819 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func advancedMenu(app *application) {
|
|
|
|
var option string
|
|
|
|
for option != "0" {
|
|
|
|
fmt.Print("\nAdvanced Menu\n-------------\n\n")
|
|
|
|
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.Println(err)
|
|
}
|
|
|
|
option = strings.TrimSuffix(input, "\n")
|
|
|
|
if option == "1" {
|
|
current := app.Config.Units
|
|
if current == "imperial" {
|
|
app.Config.Units = "metric"
|
|
} else {
|
|
app.Config.Units = "imperial"
|
|
}
|
|
fmt.Printf("\nChanged units from %s to %s...\n\n", current, app.Config.Units)
|
|
} else if option == "2" {
|
|
getPreciseLocation(app)
|
|
}
|
|
}
|
|
app.WaitGroup.Done()
|
|
}
|