bug_chomper: Consolidate public flag in a single place.
authortfarina <tfarina@chromium.org>
Wed, 15 Oct 2014 03:14:03 +0000 (20:14 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 15 Oct 2014 03:14:04 +0000 (20:14 -0700)
BUG=None
TEST=./run_server.sh --help and ./run_server.sh -public
R=borenet@google.com

Review URL: https://codereview.chromium.org/649303003

tools/bug_chomper/src/server/server.go

index fcd1ccc..1388d00 100644 (file)
@@ -44,7 +44,8 @@ const (
 
 // Flags:
 var (
-       port = flag.String("port", ":8000", "HTTP service address (e.g., ':8000')")
+       port   = flag.String("port", ":8000", "HTTP service address (e.g., ':8000')")
+       public = flag.Bool("public", false, "Make this server publicly accessible.")
 )
 
 var (
@@ -358,9 +359,6 @@ func handleRoot(w http.ResponseWriter, r *http.Request) {
 
 // Run the BugChomper server.
 func main() {
-       var public bool
-       flag.BoolVar(
-               &public, "public", false, "Make this server publicly accessible.")
        flag.Parse()
 
        http.HandleFunc("/", handleRoot)
@@ -368,7 +366,7 @@ func main() {
        http.Handle("/res/", http.FileServer(http.Dir(curdir)))
        log.Println("Server is running at " + scheme + "://" + localHost + *port)
        var err error
-       if public {
+       if *public {
                log.Println("WARNING: This server is not secure and should not be made " +
                        "publicly accessible.")
                scheme = "https"