diff options
author | Quentin Gliech <quentingliech@gmail.com> | 2018-07-22 00:16:51 +0200 |
---|---|---|
committer | Quentin Gliech <quentingliech@gmail.com> | 2018-07-22 00:16:51 +0200 |
commit | 8f0bb154b0c64b8d31e62267a8eee8363cf93932 (patch) | |
tree | 8400fb0c7586d0294e43f3a0eb411f297b5340a5 | |
parent | 94623b2a82485e573005fc52441dcdbe79f8d026 (diff) | |
download | git-bug-8f0bb154b0c64b8d31e62267a8eee8363cf93932.tar.gz |
webui: Add flag to specify which port to listen to
-rw-r--r-- | commands/webui.go | 12 | ||||
-rw-r--r-- | doc/bash_completion/git-bug | 3 | ||||
-rw-r--r-- | doc/man/git-bug-webui.3 | 4 | ||||
-rw-r--r-- | doc/md/git-bug_webui.md | 3 |
4 files changed, 18 insertions, 4 deletions
diff --git a/commands/webui.go b/commands/webui.go index eef15d24..c4db2ae6 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -12,10 +12,15 @@ import ( "net/http" ) +var port int + func runWebUI(cmd *cobra.Command, args []string) error { - port, err := freeport.GetFreePort() - if err != nil { - log.Fatal(err) + if port == 0 { + var err error + port, err = freeport.GetFreePort() + if err != nil { + log.Fatal(err) + } } addr := fmt.Sprintf("127.0.0.1:%d", port) @@ -50,4 +55,5 @@ var webUICmd = &cobra.Command{ func init() { RootCmd.AddCommand(webUICmd) + webUICmd.Flags().IntVarP(&port, "port", "p", 0, "Port to listen to") } diff --git a/doc/bash_completion/git-bug b/doc/bash_completion/git-bug index b357f4e0..7ab85fca 100644 --- a/doc/bash_completion/git-bug +++ b/doc/bash_completion/git-bug @@ -475,6 +475,9 @@ _git-bug_webui() flags_with_completion=() flags_completion=() + flags+=("--port=") + two_word_flags+=("-p") + local_nonpersistent_flags+=("--port=") must_have_one_flag=() must_have_one_noun=() diff --git a/doc/man/git-bug-webui.3 b/doc/man/git-bug-webui.3 index 8bba041d..ea182ff2 100644 --- a/doc/man/git-bug-webui.3 +++ b/doc/man/git-bug-webui.3 @@ -23,6 +23,10 @@ Launch the web UI \fB\-h\fP, \fB\-\-help\fP[=false] help for webui +.PP +\fB\-p\fP, \fB\-\-port\fP=0 + Port to listen to + .SH SEE ALSO .PP diff --git a/doc/md/git-bug_webui.md b/doc/md/git-bug_webui.md index caa1b975..52192260 100644 --- a/doc/md/git-bug_webui.md +++ b/doc/md/git-bug_webui.md @@ -13,7 +13,8 @@ git-bug webui [flags] ### Options ``` - -h, --help help for webui + -h, --help help for webui + -p, --port int Port to listen to ``` ### SEE ALSO |