News for hackers. Stuff that matters.
Re:Rust library for building no-boilerplate CLI apps by weinzierl on Wednesday December 04, 2024 @06:24AM (#42316466)
"Ideally CLI flags merged over top of environment variables merged over top of configuration files."

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.

Re:Rust library for building no-boilerplate CLI apps by liambigelow on Wednesday December 04, 2024 @02:02PM (#42320766)
Yeah I agree, and do the same. Likewise some config gets complex and can only be reasonably set through config. I prefer when I have a system with one base configuration struct where certain fields can be tagged as available on the command line, another subset in the environment, etc.