]> git.proxmox.com Git - cargo.git/commitdiff
Re-fix the `help` command's implementation
authorAlex Crichton <alex@alexcrichton.com>
Mon, 16 Mar 2015 13:32:50 +0000 (06:32 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 16 Mar 2015 13:32:50 +0000 (06:32 -0700)
This was accidentally broken in a recent refactoring.

Closes #1421

src/bin/cargo.rs
tests/test_cargo.rs

index 733d0dd1cf2a8de0e1cee56079d3e2d4510fc9de..e87288d1d254da8d72c8bc9c36205a223822261e 100644 (file)
@@ -118,14 +118,14 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
         // message for `cargo help`
         "help" if flags.arg_args[0] == "-h" ||
                   flags.arg_args[0] == "--help" => {
-            vec!["cargo".to_string(), "help".to_string(), "help".to_string()]
+            vec!["cargo".to_string(), "help".to_string(), "-h".to_string()]
         }
 
         // For `cargo help foo`, print out the usage message for the specified
         // subcommand by executing the command with the `-h` flag.
         "help" => {
-            vec!["cargo".to_string(), "help".to_string(),
-                 flags.arg_args[0].clone()]
+            vec!["cargo".to_string(), flags.arg_args[0].clone(),
+                 "-h".to_string()]
         }
 
         // For all other invocations, we're of the form `cargo foo args...`. We
index e0a3615b37d62f744cf3f6981dcc9e5e845234d4..04f55c6f29ed7f2e9f1df5737722f201cbc413c0 100644 (file)
@@ -105,3 +105,24 @@ test!(override_cargo_home {
     File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
     assert!(contents.contains(r#"authors = ["foo <bar>"]"#));
 });
+
+test!(cargo_help {
+    assert_that(process(&cargo_dir().join("cargo")).unwrap(),
+                execs().with_status(0));
+    assert_that(process(&cargo_dir().join("cargo")).unwrap().arg("help"),
+                execs().with_status(0));
+    assert_that(process(&cargo_dir().join("cargo")).unwrap().arg("-h"),
+                execs().with_status(0));
+    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+                       .arg("help").arg("build"),
+                execs().with_status(0));
+    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+                       .arg("build").arg("-h"),
+                execs().with_status(0));
+    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+                       .arg("help").arg("-h"),
+                execs().with_status(0));
+    assert_that(process(&cargo_dir().join("cargo")).unwrap()
+                       .arg("help").arg("help"),
+                execs().with_status(0));
+});