reading values via environment variables in bash
Reading nested environment variables is kind of impossible when using this library.
Env variables like:
APP.NESTED_CONFIG.VALUE
Don't really work in Bash, the workaround is to use a double underscore for separators __, I guess parsing would have been a bit harder if _ would be supported in that case. But from a usability perspective this is a real foodgun.
In fact, dots in environment variables aren't POSIX compliant. See https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names/2821201#2821201
Also having problems with this. Ideally a pattern like ENVIRONMENT_N_CELLS=4 should be able to match a variable environment.n_cells. A possible solution is:
1. split the variable at the first occurrence of the separator
2. check for matches
3. if none is found, split at the second occurrence
4. repeat to exhaustion
This would have the side effect that a.b_c and a.b.c would be conflicting names for the struct variables, however.
Environment::separator should be used to separate nested keys, e.g. https://github.com/rust-cli/config-rs/blob/7213a4cedd4dc24828c6c2c973b07b14b93108ae/examples/env-list/main.rs#L10-L18
Also having problems with this. Ideally a pattern like ENVIRONMENT_N_CELLS=4 should be able to match a variable environment.n_cells. A possible solution is:
As for having that kind of matching logic, the problem is we don't know the config field names at the time we read the environment. We could potentially delay reading until we are deserializing to a users struct but we would still only know about the current field being read, not every possible field, due to how serde works.