From 63081c6cc865a90cc13354c4d95c877c1c0489f2 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Sun, 20 Jan 2013 22:21:59 -0800 Subject: [PATCH] docker web -u: display the URL of the web UI --- dockerd/dockerd.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dockerd/dockerd.go b/dockerd/dockerd.go index bfec5518b3..27a1bd4783 100644 --- a/dockerd/dockerd.go +++ b/dockerd/dockerd.go @@ -414,10 +414,19 @@ func (docker *Docker) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (docker *Docker) CmdWeb(stdin io.ReadCloser, stdout io.Writer, args ...string) error { - if file, err := os.Open("dockerweb.html"); err != nil { - return err - } else if _, err := io.Copy(stdout, file); err != nil { - return err + flags := Subcmd(stdout, "web", "[OPTIONS]", "A web UI for docker") + showurl := flags.Bool("u", false, "Return the URL of the web UI") + if err := flags.Parse(args); err != nil { + return nil + } + if *showurl { + fmt.Fprintln(stdout, "http://localhost:4242/web") + } else { + if file, err := os.Open("dockerweb.html"); err != nil { + return err + } else if _, err := io.Copy(stdout, file); err != nil { + return err + } } return nil }