-
-
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
Arg::multiple prior to a position variable eats the position variable as well #161
Comments
This is because there isn't a way to determine when the multiple values stops and the next argument starts, unless you state a max or fixed number of values.
There are a few ways to tackle your problem depending on your particular situation. If the argument that accepts multiple values has a fixed or maximum number of values you can specify that by setting The other more general option is to use
Because Hopefully this helps, if not please let me know :) And thanks for taking the time to file the issue! 👍 |
I also just noticed you are using Example: // Arg with long help string which needs
// a new line printed to the user
Arg::with_name("long_help")
.short("l")
.help("This is a super long line that should be printed{n}one two lines to the user, yet still aligned nicely")
// Arg that I just visually want to put on two lines
// in the source, yet printed as one line to the user
Arg::with_name("shorter")
.short("s")
.help("This is a kind of long line which I only want \
on two lines in the source code.") Assuming I had those in a proper program and ran
|
That's an excellent tip with the strings, thanks! As for the argument problem. What I'd really like is to force it to be multiple option flags with a fixed number of inputs with something like required_inputs(1) to each one so this is legal: Which should be sufficient to disambiguate between having multiple inputs for an option and positional arguments. |
Actually I think you're right, and that just pointed out a logic bug in
I'll post back here once it's fixed. |
Allows setting `Arg::number_of_values(qty)` where `qty` < 2. This allows things such as `Arg::number_of_values(1)` in conjuction with `Arg::multiple(true)` which would make invoking the program like this `myprog --opt val --opt val` legal, but `myprog --opt val1 val2` illegal. Closes #161
Once Travis passes #162 I'll merge into master and upload v1.1.2 to Crates.io |
v1.1.2 on crates.io is now good to use :) |
I have this matches:
With the attempted run of:
"disburse --config hosts.json --inline --host host1 --host host2 -n 2 'sleep 10'"
matches.value_of("command") is populated however with:
"disburse --config hosts.json --inline --host host1 --host host2 'sleep 10'"
matches.value_of("command") is not populated.
The text was updated successfully, but these errors were encountered: