diff options
author | Markus Teich <markus.teich@stusta.mhn.de> | 2016-04-24 02:50:26 +0200 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2016-04-24 02:50:26 +0200 |
commit | 5cc44e5f0566b41805ddf64d96e1cbaca2ff6914 (patch) | |
tree | 9ad42a51bbb035a71caa9b8d51da207081fecc2a | |
parent | a033b4735a41ab9d2197ea458f9e05c7a73a2c00 (diff) |
aat-frontend: add option for monochrome output
-rw-r--r-- | frontends/ascii-art-table.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/frontends/ascii-art-table.go b/frontends/ascii-art-table.go index e8a0d7a..783b0f5 100644 --- a/frontends/ascii-art-table.go +++ b/frontends/ascii-art-table.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "math" + "os" "regexp" "strings" "time" @@ -15,8 +16,9 @@ import ( ) type aatConfig struct { - coords bool - unit iface.UnitSystem + coords bool + monochrome bool + unit iface.UnitSystem } //TODO: replace s parameter with printf interface? @@ -365,7 +367,8 @@ func (c *aatConfig) printDay(day iface.Day) (ret []string) { } func (c *aatConfig) Setup() { - flag.BoolVar(&c.coords, "aat-coords", false, "Show geo coordinates") + flag.BoolVar(&c.coords, "aat-coords", false, "aat-frontend: Show geo coordinates") + flag.BoolVar(&c.monochrome, "aat-monochrome", false, "aat-frontend: Monochrome output") } func (c *aatConfig) Render(r iface.Data, unitSystem iface.UnitSystem) { @@ -373,6 +376,9 @@ func (c *aatConfig) Render(r iface.Data, unitSystem iface.UnitSystem) { fmt.Printf("Weather for %s%s\n\n", r.Location, c.formatGeo(r.GeoLoc)) stdout := colorable.NewColorableStdout() + if c.monochrome { + stdout = colorable.NewNonColorable(os.Stdout) + } out := c.formatCond(make([]string, 5), r.Current, true) for _, val := range out { |