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

multi_string_flag.go - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 25e9b9fe9c71ffc9ed803fcc19841948bdd72e31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
}

// Split each flag
func (s *MultiStringFlag) Split() (result []string) {
	for _, str := range *s {
		result = append(result, strings.Split(str, ",")...)
	}

	return
}