diff --git a/src/cargo/ops/registry/search.rs b/src/cargo/ops/registry/search.rs index 652730f1f..1b6792f4f 100644 --- a/src/cargo/ops/registry/search.rs +++ b/src/cargo/ops/registry/search.rs @@ -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 {literal:#}`", + ))?; + } + Ok(()) } diff --git a/tests/testsuite/search.rs b/tests/testsuite/search.rs index 55b74459c..b7f27dd9f 100644 --- a/tests/testsuite/search.rs +++ b/tests/testsuite/search.rs @@ -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 ` + +"#]]) .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 ` "#]]) .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 ` + +"#]]) .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 ` + +"#]]) .run(); }