From 86b01ef774b14377db91f5ce2511162ae772cd70 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Tue, 24 Sep 2013 03:24:34 +0000 Subject: [PATCH] better flag use --- go/door_daemon_zmq/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/go/door_daemon_zmq/main.go b/go/door_daemon_zmq/main.go index 28be188..8b359d0 100644 --- a/go/door_daemon_zmq/main.go +++ b/go/door_daemon_zmq/main.go @@ -19,15 +19,24 @@ import ( // ---------- Main Code ------------- +var ( + cmd_port_ string + pub_port_ string +) + func usage() { fmt.Fprintf(os.Stderr, "Usage: door_daemon_0mq \n") flag.PrintDefaults() } -func main() { +func init() { + flag.StringVar(&cmd_port_, "cmdport", "tcp://localhost:5555", "zmq command socket path") + flag.StringVar(&pub_port_, "pubport", "gmp://*:6666", "zmq public/listen socket path") flag.Usage = usage flag.Parse() +} +func main() { args := flag.Args() if len(args) < 1 { fmt.Fprintf(os.Stderr, "Input file is missing!\n"); @@ -35,7 +44,7 @@ func main() { os.Exit(1); } - cmd_chans, pub_chans := ZmqsInit("tcp://localhost:5555", "gmp://*:6666") + cmd_chans, pub_chans := ZmqsInit(cmd_port_, pub_port_) serial_wr, serial_rd, err := OpenAndHandleSerial(args[0], pub_chans.Out()) if err != nil { -- 1.7.10.4