mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-12 06:30:49 -05:00
52 lines
952 B
Go
52 lines
952 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"bufio"
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"os"
|
||
|
"strings"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
|
||
|
var option string
|
||
|
var wg sync.WaitGroup
|
||
|
|
||
|
fmt.Println("\n==============================================")
|
||
|
fmt.Println("| Welcome to the OpenWeatherMap-gRPC Client! |")
|
||
|
fmt.Print("==============================================\n")
|
||
|
|
||
|
for option != "0" {
|
||
|
|
||
|
fmt.Print("\nMain Menu\n---------\n\n")
|
||
|
|
||
|
fmt.Println("1. Today's forecast (use current location)")
|
||
|
fmt.Println("2. Advanced options")
|
||
|
fmt.Print("0. Exit\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" {
|
||
|
fmt.Println("Option 1 selected...")
|
||
|
} else if option == "2" {
|
||
|
wg.Add(1)
|
||
|
go advancedMenu(&wg)
|
||
|
wg.Wait()
|
||
|
} else if option == "0" {
|
||
|
return
|
||
|
} else {
|
||
|
fmt.Print("\nOops! An error occurred, please choose a valid option.\n\n")
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|