@@ -302,7 +302,7 @@ func (f *FlagSetFiller) processStringSlice(fieldRef interface{}, hasDefaultTag b
302302 _ = f .processCustom (
303303 fieldRef ,
304304 func (s string ) (interface {}, error ) {
305- return parseStringSlice (s ), nil
305+ return parseStringSlice (s , f . options . valueSplitPattern ), nil
306306 },
307307 hasDefaultTag ,
308308 tagDefault ,
@@ -314,12 +314,20 @@ func (f *FlagSetFiller) processStringSlice(fieldRef interface{}, hasDefaultTag b
314314 return
315315 }
316316 if hasDefaultTag {
317- * casted = parseStringSlice (tagDefault )
317+ * casted = parseStringSlice (tagDefault , f . options . valueSplitPattern )
318318 }
319- flagSet .Var (& strSliceVar {ref : casted , override : override }, renamed , usage )
319+ flagSet .Var (& strSliceVar {
320+ ref : casted ,
321+ override : override ,
322+ valueSplitPattern : f .options .valueSplitPattern ,
323+ }, renamed , usage )
320324 if aliases != "" {
321325 for _ , alias := range strings .Split (aliases , "," ) {
322- flagSet .Var (& strSliceVar {ref : casted , override : override }, alias , usage )
326+ flagSet .Var (& strSliceVar {
327+ ref : casted ,
328+ override : override ,
329+ valueSplitPattern : f .options .valueSplitPattern ,
330+ }, alias , usage )
323331 }
324332 }
325333}
@@ -634,8 +642,9 @@ func (f *FlagSetFiller) processCustom(fieldRef interface{}, converter func(strin
634642}
635643
636644type strSliceVar struct {
637- ref * []string
638- override bool
645+ ref * []string
646+ override bool
647+ valueSplitPattern string
639648}
640649
641650func (s * strSliceVar ) String () string {
@@ -646,7 +655,7 @@ func (s *strSliceVar) String() string {
646655}
647656
648657func (s * strSliceVar ) Set (val string ) error {
649- parts := parseStringSlice (val )
658+ parts := parseStringSlice (val , s . valueSplitPattern )
650659
651660 if s .override {
652661 * s .ref = parts
@@ -658,8 +667,12 @@ func (s *strSliceVar) Set(val string) error {
658667 return nil
659668}
660669
661- func parseStringSlice (val string ) []string {
662- splitter := regexp .MustCompile ("[\n ,]" )
670+ func parseStringSlice (val string , valueSplitPattern string ) []string {
671+ if valueSplitPattern == "" {
672+ return []string {val }
673+ }
674+
675+ splitter := regexp .MustCompile (valueSplitPattern )
663676 parts := splitter .Split (val , - 1 )
664677
665678 // trim out blank parts
0 commit comments