-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Question/Idea: Parse config file via clap-rs? #1519
Comments
I had this same idea recently. I am using using clap for my cli and reading from a toml config file, and they share some options. Serde converts the toml file into a separate struct, so for now I'll have to validate them separately. But it would be great to have some type of integration. |
@comfortablynick Would you be able to use |
Here is proof-of-concept work on parsing a config file. |
#1693 should be fixing this. I would like to close this issue in favour of that. Please reopen with arguments if I missed something. |
I have a program which looks like this:
The program works great, because its a great program, but something that I would like to be able to do is use a config file instead of specify all of these options via the cli at runtime. Is there a way to leverage the backend logic that gets built by clap where it parses and validates all or some of the options that I would normally have to type as arguments? For instance if I was to make a file that contained the following:
Would it be possible using clap to have something which makes the following commands equivelant:
Or is the correct answer that I would have to build a seperate parsing and validating system for when the option of a config file is preseted and ensure that the logic matches the logic setup by the clap parsing engine? If this a completely idiotic question please just point me in the right direction, if this is not a completely dumb question and it does not currently exist inside of clap is it a feature the clap-rs project would be interested in integrating? Also if there is a better venue for this conversation please let me know. Thanks in advance for any help/insight you may be able to provide!
The text was updated successfully, but these errors were encountered: