-
Notifications
You must be signed in to change notification settings - Fork 31
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 - set config values by path #62
Comments
Ideally, it would be style-preserving too 😄 |
Yes. This is the way string keys work everywhere. See the
Parse the CLI value(s) using something like // The value can be anything `Serialize`. `figment::value::Value` is a good choice.
let overrides: Vec<(String, figment::value::Value)> = /* result from CLI parsing */;
let mut figment = /* whatever your figment looks like */;
for override in overrides {
figment = figment.merge(override);
} You can even add provenance information to these CLI values by implementing a custom provider, which will give you perfect error messages should something go wrong, but it's not required. |
ah nice, that's quite powerful. Did I miss this in the docs? |
It is documented, though perhaps not as well as it should be. I've added this detail to more places in the docs. |
i see that it's possible to extract values from configuration using a period-delimited 'path'
str
. Is there anyway to do the inverse operation? That is, set a nested value using the path to the key.The use case i'm envisaging is that
I had imagined an interface like
what's the best way to approach this using your library?
The text was updated successfully, but these errors were encountered: