2024-08-11 16:13:35 +01:00
|
|
|
package flag
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
type StringSliceValue []string
|
|
|
|
|
|
|
|
func NewStringSliceValue() StringSliceValue {
|
|
|
|
arr := make([]string, 0, 3)
|
|
|
|
|
|
|
|
return StringSliceValue(arr)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v StringSliceValue) String() string {
|
|
|
|
return strings.Join(v, ", ")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *StringSliceValue) Set(value string) error {
|
|
|
|
if len(value) > 0 {
|
|
|
|
*v = append(*v, value)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-11 17:05:41 +01:00
|
|
|
|
|
|
|
func (v StringSliceValue) Empty() bool {
|
|
|
|
return len(v) == 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v StringSliceValue) ExpectedLength(expectedLength int) bool {
|
|
|
|
return len(v) == expectedLength
|
|
|
|
}
|