-
-
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
Feature request: Add support for multiple required arguments, e.g. [-u <mode> <file> <mime>] #88
Comments
We can't have the `-u <mode> <file> <mime>` style yet, but clap-rs/clap#88 might help with that at some point. Related to #92 and #81
Ok, I'll have look at how best (most ergonomically) do this. In the mean time, the let modes = ["resumable", "simple"];
let _ = App::new("app")
.arg(Arg::from_usage("-u [mode] 'the mode'").possible_values(&modes).requires("file"))
.arg(Arg:from_usage("-f [file] 'the file'").requires("mode"))
.arg_from_usage("<group-id> 'the group id'")
.get_matches(); This works by if the user does a Also, in ref to your last statement, that's exactly what I plan with #82 👍 It does this minimally right now (i.e. based off your current usage in the example, But I plan on making it much clearer in the very near future. |
Thanks for much for having a look ! I will try that once again, tomorrow (note to self). Must have been some silly mistake on my side, amplified by #82 - if it would tell you the possible values of the required flag, it would have been clear which name to put there. I will be working like a maniac until 15th of May, and am sure the few remaining kinks will be etched out until then. Generally |
Mistakenly closed by commit message |
This is closed with v0.7.1 on crates.io See the new docs or #89 for details on the changes - it should help out! Also, I'm quite happy with the new smarter usage strings which take the current attempted usage as a template for what's required, not just the defaults. |
Thank you, this defintely works now. I could also verify that |
I need to support an optional argument like the one noted in the subject, but was unable to achieve this. Apparently there is no support for multiple arguments of a single flag.
docopt
can do this though, and I believe its a useful feature to have.A workaround I tried was to use the
Arg::requires()
method to enforce flags to appear together. However, a doubly-linked requires definition doesn't seem to work. For example, in the following excerpt I want-u
to appear with-f
and vice-versa.In code, this looks like this (example is manufactured, and not actual code, might not compile)
Maybe I am doing it wrong though. The code above results in runtime errors like this:
In any case, it would be very helpful to print which dependencies are actually missing :).
Thanks for your help !
The text was updated successfully, but these errors were encountered: