From d2613b543db5c2d9c1f48d79d47bfcf7c1388f92 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 16 Apr 2018 15:15:44 +0100 Subject: Use description of weather rather than just the type number --- weather.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/weather.go b/weather.go index 8325c41..25142cd 100644 --- a/weather.go +++ b/weather.go @@ -1,10 +1,10 @@ package main +// BUG: need to allow choice of met-office source (-b 0 doesn't work how i thought it would) // TODO: allow free-text lookups of place names, rather than ids // TODO: convert metoffice windspeed to mph // TODO: split output into days // TODO: add -n flag to only output a certain number of days -// TODO: convert weather type number into a human-friendly string // TODO: human friendly dates import ( @@ -100,6 +100,16 @@ type WeatherParams struct { WT int // Weather Type } +// TODO: complete this mapping +var TypeDescription = map[int]string{ + 0: "Clear Sky", + 1: "Sunny", + 2: "Partly Cloudy", + 3: "Sunny Intervals", + 7: "Light Cloud", + 12: "Light Rain", +} + // Our prefered struct type Weather struct { date string @@ -217,7 +227,7 @@ func main() { for _, w := range weather { fmt.Printf("%s %s ", w.date, w.time) - fmt.Printf("Type: %2d, Temp: %4.1f°C, ", w.weathertype, w.temperature) + fmt.Printf("%15s, Temp: %4.1f°C, ", TypeDescription[w.weathertype], w.temperature) fmt.Printf("Rain: %2d%%, Wind: %4.1fmph\n", w.precipitation, w.windspeed) if *verbose { fmt.Printf(" %+v\n", w) -- cgit v1.2.3