Rollup merge of #99100 - Smittyvb:test-cli-binary-name, r=thomcc
Fix binary name in help message for test binaries Currently the help output for a test binary uses the first argument instead of the binary name in the help output: ``` $ cargo test -- --help ... Usage: --help [OPTIONS] [FILTERS...] ... ``` This fixes it to use the name of the binary (or `...` if there is no binary name passed on argv): ``` $ cargo test -- --help ... Usage: /tmp/x/target/debug/deps/x-80c11a15ad4e1bf3 [OPTIONS] [FILTERS...] ... ```
This commit is contained in:
commit
76f968dadc
1 changed files with 2 additions and 1 deletions
|
@ -196,6 +196,7 @@ Test Attributes:
|
||||||
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
||||||
// Parse matches.
|
// Parse matches.
|
||||||
let opts = optgroups();
|
let opts = optgroups();
|
||||||
|
let binary = args.get(0).map(|c| &**c).unwrap_or("...");
|
||||||
let args = args.get(1..).unwrap_or(args);
|
let args = args.get(1..).unwrap_or(args);
|
||||||
let matches = match opts.parse(args) {
|
let matches = match opts.parse(args) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
|
@ -205,7 +206,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
||||||
// Check if help was requested.
|
// Check if help was requested.
|
||||||
if matches.opt_present("h") {
|
if matches.opt_present("h") {
|
||||||
// Show help and do nothing more.
|
// Show help and do nothing more.
|
||||||
usage(&args[0], &opts);
|
usage(binary, &opts);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue