Skip to content

Commit

Permalink
Switch cargo search output to stdout
Browse files Browse the repository at this point in the history
Closes #4203
  • Loading branch information
alexcrichton committed Jun 23, 2017
1 parent 534ce68 commit deda31f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,17 @@ pub fn search(query: &str,
}
None => name
};
writeln!(config.shell().err(), "{}", line)?;
println!("{}", line);
}

let search_max_limit = 100;
if total_crates > limit as u32 && limit < search_max_limit {
writeln!(config.shell().err(),
"... and {} crates more (use --limit N to see more)",
total_crates - limit as u32)?;
println!("... and {} crates more (use --limit N to see more)",
total_crates - limit as u32);
} else if total_crates > limit as u32 && limit >= search_max_limit {
writeln!(config.shell().err(),
"... and {} crates more (go to http://crates.io/search?q={} to see more)",
println!("... and {} crates more (go to http://crates.io/search?q={} to see more)",
total_crates - limit as u32,
percent_encode(query.as_bytes(), QUERY_ENCODE_SET))?;
percent_encode(query.as_bytes(), QUERY_ENCODE_SET));
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions tests/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn simple() {
assert_that(cargo_process("search").arg("postgres")
.arg("--host").arg(registry().to_string()),
execs().with_status(0)
.with_stderr_contains("\
.with_stdout_contains("\
hoare = \"0.1.1\" # Design by contract style assertions for Rust"));
}

Expand Down Expand Up @@ -134,7 +134,7 @@ fn multiple_query_params() {
assert_that(cargo_process("search").arg("postgres").arg("sql")
.arg("--host").arg(registry().to_string()),
execs().with_status(0)
.with_stderr_contains("\
.with_stdout_contains("\
hoare = \"0.1.1\" # Design by contract style assertions for Rust"));
}

Expand Down

0 comments on commit deda31f

Please sign in to comment.