-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
TrailingVarArg with hyphens #558
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
Comments
|
Sorry, I messed up the description. Updated. |
This appears to be a bug, thanks for filing! Like @clux said, the setting should be on the subcommand it affects. You can also use I'm looking into this bug now as to why it only works when the first argument doesn't start with a hyphen. I'll post back here with what I find. |
#560 fixes this. Also, part of the problem is you need to add This should be a passing test once the PR merges: #[test]
fn test_vararg_2() {
let m = App::new("myprog")
.subcommand(SubCommand::with_name("sub")
.setting(AppSettings::TrailingVarArg)
.setting(AppSettings::AllowLeadingHyphen) // <-- Only change
.arg(Arg::from_usage("<cmd>... 'commands to run'")))
.get_matches_from(vec!["myprog", "sub", "--arg1", "-r", "val1"]);
let trail: Vec<&str> =
m.subcommand_matches("sub").unwrap().values_of("cmd").unwrap().collect();
assert_eq!(trail, ["--arg1", "-r", "val1"]);
} |
That was fast! Thanks! Looking forward to the completion work you've done in #560. |
#278 shows how to use
TrailingVarArg
and a multiple arg to capture extra args. This works great, but I can't seem to get it working with args that start with hyphens:The text was updated successfully, but these errors were encountered: