From 24ae9a30339be933ab094aa7a542c48861772ea1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 9 May 2019 07:00:38 -0700 Subject: [PATCH] add a -nogui option for debugging Signed-off-by: Jeff Carr --- Makefile | 4 ++++ config.go | 9 +++++++-- main.go | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2892f4f..058c2f0 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,10 @@ run: go build ./cloud-control-panel +nogui: + go build + ./cloud-control-panel -nogui + gaper: # 'gaper' is a simple and smart golang tool that just rebuilds every time you change a file # go get -u github.com/maxcnunes/gaper diff --git a/config.go b/config.go index 961d7c4..39b6207 100644 --- a/config.go +++ b/config.go @@ -33,7 +33,7 @@ var customUsage = func() { func parseFlags() { var version string - var race bool + var nogui bool var hostname string var width int var height int @@ -44,7 +44,7 @@ func parseFlags() { flag.IntVar (&width, "width", 400, "Width of the Window") flag.IntVar (&height, "height", 600, "Height of the Window") - flag.BoolVar (&race, "race", race, "Use race detector") + flag.BoolVar (&nogui, "nogui", nogui, "Do not display the GUI") // Set the output if something fails to stdout rather than stderr flag.CommandLine.SetOutput(os.Stdout) @@ -61,6 +61,7 @@ func parseFlags() { config.Set("width", width) config.Set("height", height) config.Set("hostname", hostname) + config.Set("nogui", nogui) } func parseConfig() { @@ -101,4 +102,8 @@ func parseConfig() { hostname := config.String("cloud." + account + ".hostname") fmt.Println(hostname, port, proto) } + + if (config.String("nogui") == "true") { + log.Println("DO NOT DISPLAY THE GUI") + } } diff --git a/main.go b/main.go index b323285..c4a3501 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,12 @@ import "git.wit.com/wit/gui" func main() { parseConfig() + // only test the socket code if no GUI + if (config.String("nogui") == "true") { + retrySocket() + onExit() + } + go gui.DoGUI() go retrySocket()