Skip to content
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

Validating parsing of ini file #29

Open
vi opened this issue Mar 17, 2021 · 2 comments
Open

Validating parsing of ini file #29

vi opened this issue Mar 17, 2021 · 2 comments

Comments

@vi
Copy link

vi commented Mar 17, 2021

How do I make it check errors (e.g. wrong fields or section names) when parsing the ini file?
Ideally clap-like suggestions should be shown when invalid name is close to some valid name.

@marioortizmanero
Copy link
Owner

marioortizmanero commented Mar 25, 2021

How do I make it check errors (e.g. wrong fields or section names) when parsing the ini file?
Ideally clap-like suggestions should be shown when invalid name is close to some valid name.

That is currently not implemented. The library only seeks to glue both rust-ini and clap under the same interface, with no additional features. So not sure if that's the goal here. But would some kind of hook that validates the INI config file be enough?

Something like:

let conf = ServerConfig::parse_with_validation(app, "config.ini", |ini, args| -> bool { /* ... */ });

Where the function would be called before reading the arguments/INI into the config file?

@vi
Copy link
Author

vi commented Mar 26, 2021

Expected high-level API should be similar to the non-validating one: just ask for info and automatically provide error message to user in case of problems.

It should work just like Clap's validation and auto-suggestion of command line arguments, but also for INI instream of CLI.

Also somewhat like #[serde(deny_unknown_fields)].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants