diff options
author | Nick White <git@njw.name> | 2018-03-22 16:26:17 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2018-03-22 16:27:14 +0000 |
commit | 12e6824b8f0e6f6bb1ea921aa26a2d485fc9dcd9 (patch) | |
tree | dd0842cfb7eb1494df596a851df99b1a59e072fc | |
parent | e2b29a75f139e163872dee499626596c754fc566 (diff) | |
download | weather-12e6824b8f0e6f6bb1ea921aa26a2d485fc9dcd9.tar.bz2 weather-12e6824b8f0e6f6bb1ea921aa26a2d485fc9dcd9.zip |
Add -v flag
-rw-r--r-- | weather.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -4,7 +4,6 @@ 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 import ( "encoding/json" @@ -58,7 +57,10 @@ type WeatherParams struct { WT int // Weather Type } -var numdays = flag.Int("n", 2, "number of days to show") +var ( + numdays = flag.Int("n", 2, "number of days to show") + verbose = flag.Bool("v", false, "verbose: show all weather details") +) func main() { var r Response @@ -102,4 +104,7 @@ func main() { func prettyWeather(t string, w WeatherParams) { fmt.Printf("%s Type: %2d, Temp: %4.1f°C, Rain: %2d%%, Wind: %2.1fm/s\n", t, w.WT, w.T, w.PP, w.WS) + if *verbose { + fmt.Printf(" %+v\n", w) + } } |