Skip to content
Snippets Groups Projects
Verified Commit b5aaa4e5 authored by meskio's avatar meskio :tent:
Browse files

[feat] add a command line flag to enable gateway selection

- Resolves: #12
parent fd5b9b59
No related branches found
No related tags found
1 merge request!3[bug] check if error is not nil before checking if it's nopolkit
......@@ -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())
}
......
......@@ -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", "")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment