From 8f0bb154b0c64b8d31e62267a8eee8363cf93932 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Sun, 22 Jul 2018 00:16:51 +0200 Subject: webui: Add flag to specify which port to listen to --- commands/webui.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'commands') 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") } -- cgit