]> git.lizzy.rs Git - rust.git/blobdiff - library/test/src/cli.rs
Fix binary name in help message for test binaries
[rust.git] / library / test / src / cli.rs
index 000f5fa3f5860842463b8ca38afa0630879c3696..f981b9c4954762c21ceee2d44325934090c38405 100644 (file)
@@ -196,6 +196,7 @@ fn usage(binary: &str, options: &getopts::Options) {
 pub fn parse_opts(args: &[String]) -> Option<OptRes> {
     // Parse matches.
     let opts = optgroups();
+    let binary = args.get(0).map(|c| &**c).unwrap_or("...");
     let args = args.get(1..).unwrap_or(args);
     let matches = match opts.parse(args) {
         Ok(m) => m,
@@ -205,7 +206,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
     // Check if help was requested.
     if matches.opt_present("h") {
         // Show help and do nothing more.
-        usage(&args[0], &opts);
+        usage(binary, &opts);
         return None;
     }