From c6f0b4d1bcce7f6848cb776dfcab08dab790776a Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Thu, 30 Oct 2014 18:27:37 -0500 Subject: [PATCH] Add flag --skip-open/-s to skip browser opening on start, closes #50 --- README.md | 1 + main.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index e0bf48a..e4872fb 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ Application Options: --listen= HTTP server listen port (8080) --auth-user= HTTP basic auth user --auth-pass= HTTP basic auth password + -s, --skip-open Skip browser open on start ``` ## Compile from source diff --git a/main.go b/main.go index 8b0b4e3..683b1de 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ var options struct { HttpPort uint `long:"listen" description:"HTTP server listen port" default:"8080"` AuthUser string `long:"auth-user" description:"HTTP basic auth user"` AuthPass string `long:"auth-pass" description:"HTTP basic auth password"` + SkipOpen bool `short:"s" long:"skip-open" description:"Skip browser open on start"` } var dbClient *Client @@ -132,6 +133,10 @@ func openPage() { url := fmt.Sprintf("http://localhost:%v", options.HttpPort) fmt.Println("To view database open", url, "in browser") + if options.SkipOpen { + return + } + _, err := exec.Command("which", "open").Output() if err != nil { return