Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@bytemark.co.uk>2016-05-05 15:16:32 +0300
committerNick Thomas <me@ur.gs>2016-09-09 01:56:37 +0300
commit33fca0976f95eac7ddce424080db9e381ec7388e (patch)
treeb0879a1eba1b3be67ec867d1b8a3027b5f0e2168 /multi_string_flag.go
parent62b22d776ebf3115e0ed2ae46191f40ae71fc0a7 (diff)
Allow -listen-http, -listen-https and -listen-proxy to be given more than once
Per issue #13, sometimes you want to listen on more than one port for each type of listener. This commit adds support for that.
Diffstat (limited to 'multi_string_flag.go')
-rw-r--r--multi_string_flag.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/multi_string_flag.go b/multi_string_flag.go
new file mode 100644
index 00000000..ba6d92ea
--- /dev/null
+++ b/multi_string_flag.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "strings"
+)
+
+// MultiStringFlag implements the flag.Value interface and allows a string flag
+// to be specified multiple times on the command line.
+//
+// e.g.: -listen-http 127.0.0.1:80 -listen-http [::1]:80
+type MultiStringFlag []string
+
+// String returns the list of parameters joined with a commas (",")
+func (s *MultiStringFlag) String() string {
+ return strings.Join(*s, ",")
+}
+
+// Set appends the value to the list of parameters
+func (s *MultiStringFlag) Set(value string) error {
+ *s = append(*s, value)
+ return nil
+}