weather-cli/cmd/client/main.go

52 lines
952 B
Go
Raw Normal View History

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")
}
}
}