From cade9fbd3dd9e712acf61fbd1d5280f988c774c2 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 13 Aug 2024 09:39:26 -0400 Subject: [PATCH] assistant: Show a better error when `/docs` is used without a package name (#16157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR makes it so that running `/docs` without providing a package name gives a better error message: Screenshot 2024-08-13 at 9 24 58 AM Screenshot 2024-08-13 at 9 25 05 AM Release Notes: - N/A --- crates/assistant/src/slash_command/docs_command.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/assistant/src/slash_command/docs_command.rs b/crates/assistant/src/slash_command/docs_command.rs index 075542f745..8a528249bb 100644 --- a/crates/assistant/src/slash_command/docs_command.rs +++ b/crates/assistant/src/slash_command/docs_command.rs @@ -276,6 +276,15 @@ impl SlashCommand for DocsSlashCommand { } => (provider, item_path), }; + if key.trim().is_empty() { + let package_term = match provider.as_ref() { + "docs-rs" | "rustdoc" => "crate", + _ => "package", + }; + + bail!("no {package_term} name provided"); + } + let store = store?; if let Some(package) = args.package() {