From a688c5a1d929e80b0b92074b46d3c113abdbe617 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Mon, 8 Aug 2022 05:56:25 -0400 Subject: [PATCH] Minor updates to prompts and error messages --- cmd/advanced.go | 4 ++-- cmd/history.go | 10 +--------- cmd/main.go | 2 -- cmd/menu.go | 8 ++++---- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/cmd/advanced.go b/cmd/advanced.go index ada31b6..46c9c1d 100644 --- a/cmd/advanced.go +++ b/cmd/advanced.go @@ -83,8 +83,8 @@ func validateHistorical(app *Application) bool { if app.HistoricalForecast.Temp != -500.00 { isValid = true } else { - fmt.Println("I couldn't get any information for that location.") - fmt.Println("Please double check the location you entered.") + fmt.Println("I couldn't get any information for that location and date.") + fmt.Println("Please double check the information you entered.") } return isValid } diff --git a/cmd/history.go b/cmd/history.go index 55b9f62..98959d8 100644 --- a/cmd/history.go +++ b/cmd/history.go @@ -11,9 +11,7 @@ import ( // Get a date from the user and save it to the config func getDate(app *Application) { - var isValid bool - for !isValid { fmt.Print("\nEnter 4-digit year: ") _, err := fmt.Scanf("%d", &app.Config.Date.Year) @@ -40,9 +38,7 @@ func getDate(app *Application) { // Query SimplrWeather for date in Unix time func getUnixTime(c pb.RouteGuideClient) int32 { - var year, month, day int32 - res, err := c.GetUnixTime(context.Background(), &pb.Date{ Year: year, Month: month, @@ -86,11 +82,9 @@ func getHistoricalData(c pb.RouteGuideClient, app *Application) { convertUnits(app) } -// Convert historical data from standard to user defined units +// Convert historical data from standard to users preferred units func convertUnits(app *Application) { - units := app.Config.Units - switch units { case "imperial": app.HistoricalForecast.Temp = convertKToF(app.HistoricalForecast.Temp) @@ -101,9 +95,7 @@ func convertUnits(app *Application) { app.HistoricalForecast.FeelsLike = convertKToC(app.HistoricalForecast.FeelsLike) default: fmt.Println("\nUnable to convert units, temperature will default to Kelvin and speed will default to meters per second.") - return } - } // Convert Kelvin to Fahrenheit diff --git a/cmd/main.go b/cmd/main.go index b8e9760..0ee26b3 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -98,7 +98,5 @@ func main() { Version: version, Client: pb.NewRouteGuideClient(conn), } - mainMenu(&app) - } diff --git a/cmd/menu.go b/cmd/menu.go index 94d6b01..0f747da 100644 --- a/cmd/menu.go +++ b/cmd/menu.go @@ -11,9 +11,9 @@ import ( // Displays news and calls loop with menu options func mainMenu(app *Application) { - fmt.Println("\n=====================================================") - fmt.Printf("| Welcome to the OpenWeatherMap-gRPC Client! v%s |\n", app.Version) - fmt.Println("=====================================================") + fmt.Println("\n================================================") + fmt.Printf("| Welcome to the OpenWeatherMap Client! v%s |\n", app.Version) + fmt.Println("================================================") fmt.Printf("New in version %s:\n", app.Version) fmt.Println(" - Search by zip code") @@ -32,7 +32,7 @@ func mainMenuLoop(app *Application) { fmt.Println("1. Use current location (default)") fmt.Println("2. Search by zip code") fmt.Println("3. Search by city") - fmt.Println("4. Advanced options") + fmt.Println("4. Advanced options (Change units, precise location, etc.)") fmt.Print("0. Exit\n\n") // Read user input