Skip to content

Commit

Permalink
Merge pull request #687 from joshuarubin/master
Browse files Browse the repository at this point in the history
Don't clobber slices with EnvVar
  • Loading branch information
jszwedko committed Nov 28, 2017
2 parents 7ace96b + 37b7abb commit c6af884
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ func (f StringSliceFlag) ApplyWithError(set *flag.FlagSet) error {
return fmt.Errorf("could not parse %s as string value for flag %s: %s", envVal, f.Name, err)
}
}
f.Value = newVal
if f.Value == nil {
f.Value = newVal
} else {
*f.Value = *newVal
}
}

eachName(f.Name, func(name string) {
Expand Down Expand Up @@ -235,7 +239,11 @@ func (f IntSliceFlag) ApplyWithError(set *flag.FlagSet) error {
return fmt.Errorf("could not parse %s as int slice value for flag %s: %s", envVal, f.Name, err)
}
}
f.Value = newVal
if f.Value == nil {
f.Value = newVal
} else {
*f.Value = *newVal
}
}

eachName(f.Name, func(name string) {
Expand Down Expand Up @@ -292,7 +300,11 @@ func (f Int64SliceFlag) ApplyWithError(set *flag.FlagSet) error {
return fmt.Errorf("could not parse %s as int64 slice value for flag %s: %s", envVal, f.Name, err)
}
}
f.Value = newVal
if f.Value == nil {
f.Value = newVal
} else {
*f.Value = *newVal
}
}

eachName(f.Name, func(name string) {
Expand Down

0 comments on commit c6af884

Please sign in to comment.