summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2018-03-21 22:45:46 +0000
committerNick White <git@njw.name>2018-03-21 22:45:46 +0000
commitdb58b6f12ee3bd80868b4edef43dd5fad08718f2 (patch)
treedeb35a89f2c76afab8f1f929675941e11cfb3907
parent721984f06ee52484558a70f03a7859236fdef512 (diff)
downloadweather-db58b6f12ee3bd80868b4edef43dd5fad08718f2.tar.bz2
weather-db58b6f12ee3bd80868b4edef43dd5fad08718f2.zip
Reverse output ordering so most recent is last, so closest to cursor, for less paging
-rw-r--r--weather.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/weather.go b/weather.go
index eed74d9..1c51a80 100644
--- a/weather.go
+++ b/weather.go
@@ -4,6 +4,8 @@ package main
// TODO: decode weather type number
// TODO: split out met office specific stuff to separate module
// TODO: add other weather providers
+// TODO: add -v verbose flag to show all data
+// TODO: add -n flag to return a certain number of days
import (
"encoding/json"
@@ -48,8 +50,8 @@ type WeatherParams struct {
H int // Humidity
P int // Pressure
PP int // Precipitation Probability
- UV int // Max UV Index
T float64 // Temperature
+ UV int // Max UV Index
V int // Visibility
WD string // Wind Direction
WG float64 // Wind Gust
@@ -80,11 +82,12 @@ func main() {
log.Fatal(err)
}
- for _, d := range r.BestFcst.Forecast.Location.Days {
+ for i := len(r.BestFcst.Forecast.Location.Days) - 1; i >= 0; i-- {
+ d := r.BestFcst.Forecast.Location.Days[i]
fmt.Printf("-----------------------------\n")
fmt.Printf("%s\n", d.Date)
- prettyWeather("Day ", d.DayValues.WeatherParameters)
- prettyWeather("Night ", d.NightValues.WeatherParameters)
+ prettyWeather(" Day ", d.DayValues.WeatherParameters)
+ prettyWeather(" Night ", d.NightValues.WeatherParameters)
for _, t := range d.TimeSteps.TimeStep {
prettyWeather(t.Time, t.WeatherParameters)