Skip to content

Commit e689383

Browse files
committed
Auto merge of #1425 - alexcrichton:issue-1421, r=huonw
This was accidentally broken in a recent refactoring. Closes #1421
2 parents 2d2e039 + 2ff5f53 commit e689383

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/bin/cargo.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
118118
// message for `cargo help`
119119
"help" if flags.arg_args[0] == "-h" ||
120120
flags.arg_args[0] == "--help" => {
121-
vec!["cargo".to_string(), "help".to_string(), "help".to_string()]
121+
vec!["cargo".to_string(), "help".to_string(), "-h".to_string()]
122122
}
123123

124124
// For `cargo help foo`, print out the usage message for the specified
125125
// subcommand by executing the command with the `-h` flag.
126126
"help" => {
127-
vec!["cargo".to_string(), "help".to_string(),
128-
flags.arg_args[0].clone()]
127+
vec!["cargo".to_string(), flags.arg_args[0].clone(),
128+
"-h".to_string()]
129129
}
130130

131131
// For all other invocations, we're of the form `cargo foo args...`. We

tests/test_cargo.rs

+21
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,24 @@ test!(override_cargo_home {
105105
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
106106
assert!(contents.contains(r#"authors = ["foo <bar>"]"#));
107107
});
108+
109+
test!(cargo_help {
110+
assert_that(process(&cargo_dir().join("cargo")).unwrap(),
111+
execs().with_status(0));
112+
assert_that(process(&cargo_dir().join("cargo")).unwrap().arg("help"),
113+
execs().with_status(0));
114+
assert_that(process(&cargo_dir().join("cargo")).unwrap().arg("-h"),
115+
execs().with_status(0));
116+
assert_that(process(&cargo_dir().join("cargo")).unwrap()
117+
.arg("help").arg("build"),
118+
execs().with_status(0));
119+
assert_that(process(&cargo_dir().join("cargo")).unwrap()
120+
.arg("build").arg("-h"),
121+
execs().with_status(0));
122+
assert_that(process(&cargo_dir().join("cargo")).unwrap()
123+
.arg("help").arg("-h"),
124+
execs().with_status(0));
125+
assert_that(process(&cargo_dir().join("cargo")).unwrap()
126+
.arg("help").arg("help"),
127+
execs().with_status(0));
128+
});

0 commit comments

Comments
 (0)