rust-cli / book

Documentation on how to use the Rust Programming Language to develop commandline applications
https://rust-cli.github.io/book/index.html
MIT License
816 stars 108 forks source link

2.2. Using config files feedback #212

Open jpmckinney opened 1 year ago

jpmckinney commented 1 year ago

Going through the TODO on the page:

Evaluate crates that exist

https://docs.rs/config/latest/config/ seems to be the most popular crate.

Cli-args + multiple configs + env variables

clap has an env method/feature that allows setting an environment variable to read from if the CLI argument isn't present

To throw in configuration files, there's an open issue: https://github.com/clap-rs/clap/issues/748 There are also various (less popular) crates that integrate with clap by third-party authors.

Can configure do all this? Is there a nice wrapper around it?

configure hasn't had a release in 5 years. I don't think it's relevant anymore.

epage commented 1 year ago

For evaluating which config crate, we have started but not finished https://github.com/rosetta-rs/config-rosetta-rs to compare them. We plan to talk further about them in the WG-CLI meetings

For general layered config, clap's env support is unlikely sufficient. As for layered configs and clap, the most relevant link is https://github.com/clap-rs/clap/discussions/2763.