diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-07-16 22:17:43 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-07-16 22:17:43 (GMT) |
commit | a17956bde502c6629732b4710553fb3a968ec700 (patch) | |
tree | c58c215f1bcf384f66410ffa403ce0c13967db00 /src | |
parent | 7d801dc90d02a70d6d70f541bdfe20901bbe673b (diff) |
added command line option for update interval
Diffstat (limited to 'src')
-rw-r--r-- | src/helsinki.at/rhrdtime/rhrdtime.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/helsinki.at/rhrdtime/rhrdtime.go b/src/helsinki.at/rhrdtime/rhrdtime.go index 1a93f67..c90c699 100644 --- a/src/helsinki.at/rhrdtime/rhrdtime.go +++ b/src/helsinki.at/rhrdtime/rhrdtime.go @@ -28,6 +28,7 @@ import ( "fmt" "net/http" "time" + "flag" "github.com/codegangsta/martini" "github.com/gorilla/websocket" @@ -65,9 +66,24 @@ func RunMartini(ps *pubsub.PubSub) { } func main() { + interval_s := flag.String("interval", "15s", "the interval between updates, default 15s") + help := flag.Bool("help", false, "show usage") + + flag.Parse() + if *help { + flag.Usage() + return + } + + interval, err := time.ParseDuration(*interval_s) + if err != nil { + fmt.Println(err) + return + } + ps := pubsub.New(1) - ticker := time.NewTicker(time.Second * 1) + ticker := time.NewTicker(interval) go func() { for t := range ticker.C { tj, err := t.MarshalJSON() |