mirror of
https://codeberg.org/andyscott/weather-cli.git
synced 2024-11-08 05:50:51 -05:00
Minor updates to prompts and error messages
This commit is contained in:
parent
e3511cdacd
commit
a688c5a1d9
4 changed files with 7 additions and 17 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -98,7 +98,5 @@ func main() {
|
|||
Version: version,
|
||||
Client: pb.NewRouteGuideClient(conn),
|
||||
}
|
||||
|
||||
mainMenu(&app)
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue