Auto merge of #14537 - Rustin170506:rustin-patch-suggest-cargo-info, r=epage

Suggest `cargo info` command in the `cargo search` result
This commit is contained in:
bors 2024-09-17 15:55:50 +00:00
commit 32f024f788
2 changed files with 24 additions and 1 deletions

View File

@ -8,6 +8,7 @@ use anyhow::Context as _;
use url::Url;
use crate::util::style;
use crate::util::style::LITERAL;
use crate::util::truncate_with_ellipsis;
use crate::CargoResult;
use crate::GlobalContext;
@ -87,5 +88,12 @@ pub fn search(
);
}
if total_crates > 0 {
let literal = LITERAL;
shell.note(format_args!(
"to learn more about a package, run `{literal}cargo info <name>{literal:#}`",
))?;
}
Ok(())
}

View File

@ -115,7 +115,11 @@ fn not_update() {
cargo_process("search postgres")
.replace_crates_io(registry.index_url())
.with_stdout_data(SEARCH_RESULTS)
.with_stderr_data("") // without "Updating ... index"
// without "Updating ... index"
.with_stderr_data(str![[r#"
[NOTE] to learn more about a package, run `cargo info <name>`
"#]])
.run();
}
@ -128,6 +132,7 @@ fn replace_default() {
.with_stdout_data(SEARCH_RESULTS)
.with_stderr_data(str![[r#"
[UPDATING] crates.io index
[NOTE] to learn more about a package, run `cargo info <name>`
"#]])
.run();
@ -140,6 +145,11 @@ fn simple() {
cargo_process("search postgres --index")
.arg(registry.index_url().as_str())
.with_stdout_data(SEARCH_RESULTS)
.with_stderr_data(str![[r#"
[UPDATING] `[ROOT]/registry` index
[NOTE] to learn more about a package, run `cargo info <name>`
"#]])
.run();
}
@ -150,6 +160,11 @@ fn multiple_query_params() {
cargo_process("search postgres sql --index")
.arg(registry.index_url().as_str())
.with_stdout_data(SEARCH_RESULTS)
.with_stderr_data(str![[r#"
[UPDATING] `[ROOT]/registry` index
[NOTE] to learn more about a package, run `cargo info <name>`
"#]])
.run();
}