mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-22 16:36:27 +01:00
bf6c24d0f4
* [vmalert] config parser * make linter be happy * fix test * fix sprintf add test for rule validation
29 lines
554 B
Go
29 lines
554 B
Go
package flagutil
|
|
|
|
import (
|
|
"flag"
|
|
"strings"
|
|
)
|
|
|
|
// NewArray returns new Array with the given name and description.
|
|
func NewArray(name, description string) *Array {
|
|
var a Array
|
|
flag.Var(&a, name, description)
|
|
return &a
|
|
}
|
|
|
|
// Array holds an array of flag values
|
|
type Array []string
|
|
|
|
// String implements flag.Value interface
|
|
func (a *Array) String() string {
|
|
return strings.Join(*a, ",")
|
|
}
|
|
|
|
// Set implements flag.Value interface
|
|
func (a *Array) Set(value string) error {
|
|
values := strings.Split(value, ",")
|
|
*a = append(*a, values...)
|
|
return nil
|
|
}
|