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 /commands/webui.go | |
parent | 94623b2a82485e573005fc52441dcdbe79f8d026 (diff) | |
download | git-bug-8f0bb154b0c64b8d31e62267a8eee8363cf93932.tar.gz |
webui: Add flag to specify which port to listen to
Diffstat (limited to 'commands/webui.go')
-rw-r--r-- | commands/webui.go | 12 |
1 files changed, 9 insertions, 3 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") } |