summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2018-03-22 16:26:17 +0000
committerNick White <git@njw.name>2018-03-22 16:27:14 +0000
commit12e6824b8f0e6f6bb1ea921aa26a2d485fc9dcd9 (patch)
treedd0842cfb7eb1494df596a851df99b1a59e072fc
parente2b29a75f139e163872dee499626596c754fc566 (diff)
downloadweather-12e6824b8f0e6f6bb1ea921aa26a2d485fc9dcd9.tar.bz2
weather-12e6824b8f0e6f6bb1ea921aa26a2d485fc9dcd9.zip
Add -v flag
-rw-r--r--weather.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/weather.go b/weather.go
index d55297b..f14ec38 100644
--- a/weather.go
+++ b/weather.go
@@ -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)
+ }
}