summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-02-16 00:07:03 +0100
committerRuben Pollan <meskio@sindominio.net>2018-02-16 00:07:03 +0100
commitb5aaa4e519e88f8cd029a0f144f86c1fc02ba231 (patch)
tree34458ac616f819707c6f1f3ec2e05af709dca1c7
parentfd5b9b59804b51fb462b2678add95729bd78a812 (diff)
[feat] add a command line flag to enable gateway selection
- Resolves: #12
-rw-r--r--config.go8
-rw-r--r--systray.go4
2 files changed, 12 insertions, 0 deletions
diff --git a/config.go b/config.go
index 01cf6d5..d751a7b 100644
--- a/config.go
+++ b/config.go
@@ -17,6 +17,7 @@ package main
import (
"encoding/json"
+ "flag"
"os"
"path"
"time"
@@ -36,6 +37,7 @@ var (
type systrayConfig struct {
LastNotification time.Time
Donated time.Time
+ SelectWateway bool
}
func parseConfig() (*systrayConfig, error) {
@@ -52,9 +54,15 @@ func parseConfig() (*systrayConfig, error) {
dec := json.NewDecoder(f)
err = dec.Decode(&conf)
+ conf.parseFlags()
return &conf, err
}
+func (c *systrayConfig) parseFlags() {
+ flag.BoolVar(&c.SelectWateway, "select-gateway", false, "Enable gateway selection")
+ flag.Parse()
+}
+
func (c *systrayConfig) hasDonated() bool {
return c.Donated.Add(oneMonth).After(time.Now())
}
diff --git a/systray.go b/systray.go
index 0d37e03..bc1cab7 100644
--- a/systray.go
+++ b/systray.go
@@ -65,6 +65,10 @@ func (bt *bmTray) onReady() {
go bt.mCancel.Hide()
systray.AddSeparator()
+ if bt.conf.SelectWateway {
+ bt.addGateways()
+ }
+
mHelp := systray.AddMenuItem("Help ...", "")
bt.mDonate = systray.AddMenuItem("Donate ...", "")
bt.mHaveDonated = systray.AddMenuItem("... I have donated", "")