-
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
Support optional arguments for options #188
Comments
BTW, I can try to implement a fix for this issue, if you think it's not too hard and doesn't lead to any serious changes in the code. |
I'll accept a PR adding support of |
OK, I am working on it. |
Just so people here are aware: I feel like the changelog notes don't do this nice feature justice! I had no idea why I should care about |
Feel free to open a PR. |
If you have ideas of improvement of the doc at the same time, any improvement on this side is very welcome. |
@ErichDonGubler Thanks for your feedback! Indeed, I think mentioning |
I'll be able to get to this probably by Wednesday -- but if you want to take care of it before then, consider my interest relinquished. :) |
No worries, I've prepared the pull request with a small update in ChangeLog. Thanks again for your suggestion. |
Sometimes options have an optional argument, for example in
rustfmt
we can use either--help
or--help=<topic>
.In order to achieve this we can use
Arg::min_values(0)
inclap
(as described here: clap-rs/clap#892), but there is no way to directly specify it instructopt
. UsingOption<String>
type for a field would fail to distinguish between no option provided at all and an option without an argument. It will returnNone
for both.It looks like a possible way to support it would be to use
Option<Option<String>>
field type which can lead tomin_values(0)
in generatedclap
code.Note that this type of options is also supported by
getopts
library:https://doc.rust-lang.org/1.1.0/getopts/fn.optflagopt.html
This issue seems to be related to #180, but it has
Option<Vec<T>>
instead ofOption<Option<T>>
The text was updated successfully, but these errors were encountered: