|
|
|
|
|
by liambigelow
563 days ago
|
|
Looks nice! I like the approach. My holy grail will still be landing on a good multi-layer configuration setup for Rust CLIs. Ideally CLI flags merged over top of environment variables merged over top of configuration files. Twelf [0] was close in unifying things, but I had some friction. Lately I've been using Schematic [1] to handle the environment + config layers, and then just a manual implementation of Clap arguments layered on top. [0] https://github.com/bnjjj/twelf. [1] https://github.com/moonrepo/schematic |
|
I used to wish for that too but I have changed my mind. I think in real world applications with many options it is preferable to not allow every option to be set in every way.
Environment variables shine for properties that vary per instances which share config files and for system properties (think $GOMAXPROCS).
Secrets should never go in the command line nor the environment.
There is no one size fits all. Arguments, environment and config files have different pros and cons and should be used accordingly.