-
-
Save matklad/0d148b1c76c576a0dc0e299962926c30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// that's the code I am using | |
SubCommand::with_name("bench") | |
.settings(&[ | |
AppSettings::UnifiedHelpMessage, | |
AppSettings::DeriveDisplayOrder, | |
AppSettings::TrailingVarArg, | |
]) | |
.about("Execute all benchmarks of a local package") | |
.after_help(help::BENCH) | |
.arg( | |
Arg::with_name("BENCHNAME").help( | |
"If specified, only run benches containing this string in their names" | |
) | |
) | |
.arg( | |
Arg::with_name("args").help( | |
"Arguments for the bench binary" | |
).multiple(true) | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for `bench foo` I get | |
matches: ArgMatches { | |
args: { | |
"BENCHNAME": MatchedArg { | |
occurs: 1, | |
vals: [ | |
"foo" | |
] | |
} | |
}, | |
subcommand: None, | |
usage: Some( | |
"USAGE:\n cargo bench [OPTIONS] [--] [ARGS]" | |
which is what I want | |
for `bench foo bar` I get | |
matches: ArgMatches { | |
args: { | |
"BENCHNAME": MatchedArg { | |
occurs: 1, | |
vals: [ | |
"foo" | |
] | |
}, | |
"args": MatchedArg { | |
occurs: 1, | |
vals: [ | |
"bar" | |
] | |
} | |
}, | |
subcommand: None, | |
usage: Some( | |
"USAGE:\n cargo bench [OPTIONS] [--] [ARGS]" | |
) | |
} | |
Thit is also what I want. | |
Now, for `cargo bench -- foo bar` I get this again: | |
matches: ArgMatches { | |
args: { | |
"BENCHNAME": MatchedArg { | |
occurs: 1, | |
vals: [ | |
"foo" | |
] | |
}, | |
"args": MatchedArg { | |
occurs: 1, | |
vals: [ | |
"bar" | |
] | |
} | |
}, | |
subcommand: None, | |
usage: Some( | |
"USAGE:\n cargo bench [OPTIONS] [--] [ARGS]" | |
) | |
} | |
And what I actually want for `bench -- foo bar` is | |
matches: ArgMatches { | |
args: { | |
"args": MatchedArg { | |
occurs: 2, | |
vals: [ | |
"foo", "bar" | |
] | |
} | |
}, | |
subcommand: None, | |
usage: Some( | |
"USAGE:\n cargo bench [OPTIONS] [--] [ARGS]" | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment