Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ func traverseStruct(value reflect.Value, flagSet *pflag.FlagSet, prefix string)
defaultBoolValue = b
}
flagSet.Bool(prefix+tag, defaultBoolValue, description)
case reflect.Slice:
if fieldValue.Type().Elem().Kind() != reflect.String {
return fmt.Errorf("unsupported slice element type %s for field %s", fieldValue.Type().Elem().Kind(), field.Name)
}
flagSet.StringSlice(prefix+tag, []string{}, description)
default:
return fmt.Errorf("unsupported field type %s for field %s", fieldValue.Kind(), field.Name)
}
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestBindConfigToFlags(t *testing.T) {
CustomFlagStruct2 struct {
CustomFlagDuration time.Duration `mapstructure:"custom-flag-duration-2"`
} `mapstructure:"le-strFlag"`
Slice []string `mapstructure:"slice" description:"This is a slice of strings"`
}

testStruct := test{}
Expand Down
Loading