aboutsummaryrefslogtreecommitdiffstats
path: root/commands/webui.go
diff options
context:
space:
mode:
authorQuentin Gliech <quentingliech@gmail.com>2018-07-22 00:16:51 +0200
committerQuentin Gliech <quentingliech@gmail.com>2018-07-22 00:16:51 +0200
commit8f0bb154b0c64b8d31e62267a8eee8363cf93932 (patch)
tree8400fb0c7586d0294e43f3a0eb411f297b5340a5 /commands/webui.go
parent94623b2a82485e573005fc52441dcdbe79f8d026 (diff)
downloadgit-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.go12
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")
}