webui: Add flag to specify which port to listen to

This commit is contained in:
Quentin Gliech 2018-07-22 00:16:51 +02:00
parent 94623b2a82
commit 8f0bb154b0
No known key found for this signature in database
GPG Key ID: 22D62B84552719FC
4 changed files with 18 additions and 4 deletions

View File

@ -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")
}

View File

@ -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=()

View File

@ -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

View File

@ -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