-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature-gated config-rs handling #72
Comments
You might be interested in #32 StructOpt is just a wrapper above clap. Looking at your proposition, it seems better to include this functionality directly in clap. But you may have some arguments to do it in structopt. |
I have done a sketch implementation and it is very simple to use config-rs in StructOpt. However, that is not really a great argument. |
You can point to a branch, and I'll look a it to seen what is your idea. |
@synek317 ping |
After some tries I think that there is a better way to solve this. Clap has 'default_value' attrs. If it could be 'default_value_fn' then merging config from file(s) with command line args could be done by 3rd party lib. |
@TeXitoi Could you please take a look at my solution sketch at https://www.reddit.com/r/rust/comments/81tp16/wip_platformconfig_multisource_configuration_for/ ? |
This is an enhancement, and structopt is now feature frozen. |
There is great config-rs crate that provides hierarchical configuration and deserialization into struct. I think it would be great if clap / structopt could handle feature like this. With this, one can handle app configuration that can be provided in multiple config files and/or command line all in one place and with single structure.
I suggest to add
from_opts_and_config
function that would acceptConfig
instance (from config-rs) that would provide defaults when argument is not passed in command line.I think that it is a best way because only structopt has full knowledge if and what arguments has been passed and which are mandatory and what should be default value if arg is not passed. Config crate requires that all values are defined, otherwise deserialization returns
Err
.Of course config-rs dependency should be configurable with features.
If you think it is a good idea, I could prepare some implementation.
The text was updated successfully, but these errors were encountered: