Skip to content

Commit

Permalink
Send --help output to stdout
Browse files Browse the repository at this point in the history
Fixes #4878
  • Loading branch information
tromey committed Jan 1, 2018
1 parent a88fbac commit f4537b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ pub fn exit_with_error(err: CliError, shell: &mut Shell) -> ! {
} else if fatal {
drop(shell.error(&error))
} else {
drop(writeln!(shell.err(), "{}", error))
// Non-fatal messages, like --help output, go to stdout.
println!("{}", error);
}

if !handle_cause(&error, shell) || hide {
Expand Down
5 changes: 5 additions & 0 deletions tests/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,9 @@ fn help() {
execs().with_status(0));
assert_that(cargo_process("help").arg("search"),
execs().with_status(0));
// Ensure that help output goes to stdout, not stderr.
assert_that(cargo_process("search").arg("--help"),
execs().with_stderr(""));
assert_that(cargo_process("search").arg("--help"),
execs().with_stdout_contains("[..] --frozen [..]"));
}

0 comments on commit f4537b2

Please sign in to comment.