config-rs icon indicating copy to clipboard operation
config-rs copied to clipboard

No option to exclude keys from case conversion

Open moldhouse opened this issue 1 year ago • 1 comments

Currently, it is not possible to specify a list of keys that should be excluded from case conversion.

In my case, this makes it hard to build a config from an Environment and a File, where some identifiers in the file are kebab-case, while other parameters are snake_case.

For example, I want a kebab-case key and a snake_case configuration:

# TOML configuration
[foo.kebab-case-key]
snake_case_configuration = "bar"
# Environment configuration
FOO__KEBAB_CASE_KEY__SNAKE_CASE_CONFIGURATION=bar

While there is a method convert_case, it is applied to all collected keys. For this example, a possible solution would be something like:

Environment::default().convert_case_exclude_keys(Case::Kebab, ["snake_case_configuration"]);

moldhouse avatar Dec 23 '24 16:12 moldhouse

I'm sorry for the delay; I'm still working on catching up from the holidays

To make this easier to process and avoid confusing, could you write this up like a bug report with a reproduction case, showing the actual behavior and reporting what the expected behavior is?

epage avatar Jan 28 '25 22:01 epage