-
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
Reading single line from file #58
Comments
Can you be more specific about what you want to do? An example would be great. |
Something like this. fn build_cli() -> Result<Cli> {
let mut cli = Figment::new().merge(Serialized::defaults(Cli::parse()));
if let Some(path) = CONFIG_FILE_PATH.as_ref() {
cli = cli.merge(Data::<MyOwnProviderType>::file(path.as_path()));
}
Ok(cli.extract()?)
} So what if I want a custom The file I would be looking at might look something like this: 65535 Or this: long-option = 465
another-long-option = "Hello" |
It's not clear from your example which line should be read, what should happen if the file is empty, and how the line should be parsed. But in any case, yes it would be straightforward to implement such a provider. Alternatively, you can simply read the line from the file using the |
I see you've added to your previous comment. It sounds like you want a custom provider, since your file doesn't seem to have any obvious relation to existing formats. It's not clear what the file should be parsed as, or which line you want to keep and what that line means. The figment docs are complete. See |
Yeah, I haven't figured out any specifics in terms of how things will be parsed. I just wanted to find out how to extend it. Thank you. |
Is it possible to do this with figment?
If so, where should I be looking?
The text was updated successfully, but these errors were encountered: