diff options
author | Michael Muré <batolettre@gmail.com> | 2021-02-28 21:39:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-28 21:39:57 +0100 |
commit | 87bc42fb4695872b82cfa9a922d423df7ff21132 (patch) | |
tree | 10067adb2ec24b4aa9f27ca2b0caa7da2055c618 | |
parent | 78ca2783191e363ea192fa0c18bdd5c4e615bb8a (diff) | |
parent | ea329aed6909cac85680dbae37f6f4dcca134f8b (diff) | |
download | git-bug-87bc42fb4695872b82cfa9a922d423df7ff21132.tar.gz |
Merge pull request #584 from MichaelMure/upstream-host-cmdflag
Add option to specify host address
-rw-r--r-- | commands/webui.go | 8 | ||||
-rw-r--r-- | doc/man/git-bug-webui.1 | 6 | ||||
-rw-r--r-- | doc/md/git-bug_webui.md | 11 | ||||
-rw-r--r-- | go.sum | 1 | ||||
-rw-r--r-- | misc/bash_completion/git-bug | 4 |
5 files changed, 22 insertions, 8 deletions
diff --git a/commands/webui.go b/commands/webui.go index 7e5fc752..d910a703 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -4,9 +4,11 @@ import ( "context" "fmt" "log" + "net" "net/http" "os" "os/signal" + "strconv" "time" "github.com/99designs/gqlgen/graphql/playground" @@ -27,6 +29,7 @@ import ( const webUIOpenConfigKey = "git-bug.webui.open" type webUIOptions struct { + host string port int open bool noOpen bool @@ -54,9 +57,10 @@ Available git config: flags := cmd.Flags() flags.SortFlags = false + flags.StringVar(&options.host, "host", "127.0.0.1", "Network address or hostname to listen to (default to 127.0.0.1)") flags.BoolVar(&options.open, "open", false, "Automatically open the web UI in the default browser") flags.BoolVar(&options.noOpen, "no-open", false, "Prevent the automatic opening of the web UI in the default browser") - flags.IntVarP(&options.port, "port", "p", 0, "Port to listen to (default is random)") + flags.IntVarP(&options.port, "port", "p", 0, "Port to listen to (default to random available port)") flags.BoolVar(&options.readOnly, "read-only", false, "Whether to run the web UI in read-only mode") return cmd @@ -71,7 +75,7 @@ func runWebUI(env *Env, opts webUIOptions, args []string) error { } } - addr := fmt.Sprintf("127.0.0.1:%d", opts.port) + addr := net.JoinHostPort(opts.host, strconv.Itoa(opts.port)) webUiAddr := fmt.Sprintf("http://%s", addr) router := mux.NewRouter() diff --git a/doc/man/git-bug-webui.1 b/doc/man/git-bug-webui.1 index 954250a2..6e4622be 100644 --- a/doc/man/git-bug-webui.1 +++ b/doc/man/git-bug-webui.1 @@ -22,6 +22,10 @@ Available git config: .SH OPTIONS .PP +\fB\-\-host\fP="127.0.0.1" + Network address or hostname to listen to (default to 127.0.0.1) + +.PP \fB\-\-open\fP[=false] Automatically open the web UI in the default browser @@ -31,7 +35,7 @@ Available git config: .PP \fB\-p\fP, \fB\-\-port\fP=0 - Port to listen to (default is random) + Port to listen to (default to random available port) .PP \fB\-\-read\-only\fP[=false] diff --git a/doc/md/git-bug_webui.md b/doc/md/git-bug_webui.md index 98a61eb2..ccfaff9a 100644 --- a/doc/md/git-bug_webui.md +++ b/doc/md/git-bug_webui.md @@ -17,11 +17,12 @@ git-bug webui [flags] ### Options ``` - --open Automatically open the web UI in the default browser - --no-open Prevent the automatic opening of the web UI in the default browser - -p, --port int Port to listen to (default is random) - --read-only Whether to run the web UI in read-only mode - -h, --help help for webui + --host string Network address or hostname to listen to (default to 127.0.0.1) (default "127.0.0.1") + --open Automatically open the web UI in the default browser + --no-open Prevent the automatic opening of the web UI in the default browser + -p, --port int Port to listen to (default to random available port) + --read-only Whether to run the web UI in read-only mode + -h, --help help for webui ``` ### SEE ALSO @@ -476,6 +476,7 @@ github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/xanzy/go-gitlab v0.40.1 h1:jHueLh5Inzv20TL5Yki+CaLmyvtw3Yq7blbWx7GmglQ= github.com/xanzy/go-gitlab v0.40.1/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= +github.com/xanzy/go-gitlab v0.44.0 h1:cEiGhqu7EpFGuei2a2etAwB+x6403E5CvpLn35y+GPs= github.com/xanzy/go-gitlab v0.44.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug index 3cedd86a..8f2a0f8f 100644 --- a/misc/bash_completion/git-bug +++ b/misc/bash_completion/git-bug @@ -1331,6 +1331,10 @@ _git-bug_webui() flags_with_completion=() flags_completion=() + flags+=("--host=") + two_word_flags+=("--host") + local_nonpersistent_flags+=("--host") + local_nonpersistent_flags+=("--host=") flags+=("--open") local_nonpersistent_flags+=("--open") flags+=("--no-open") |