diff --git a/crates/uv/src/commands/tool/list.rs b/crates/uv/src/commands/tool/list.rs index efe57f9e10dde..506da512dc459 100644 --- a/crates/uv/src/commands/tool/list.rs +++ b/crates/uv/src/commands/tool/list.rs @@ -20,10 +20,11 @@ pub(crate) async fn list( printer: Printer, ) -> Result { let installed_tools = InstalledTools::from_settings()?; + let no_tools_installed_msg = "No tools installed.\n\nSee `uv tool install --help` for more information."; let _lock = match installed_tools.lock().await { Ok(lock) => lock, Err(uv_tool::Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => { - writeln!(printer.stderr(), "No tools installed")?; + writeln!(printer.stderr(), "{}", no_tools_installed_msg)?; return Ok(ExitStatus::Success); } Err(err) => return Err(err.into()), @@ -33,10 +34,16 @@ pub(crate) async fn list( tools.sort_by_key(|(name, _)| name.clone()); if tools.is_empty() { - writeln!(printer.stderr(), "No tools installed")?; + writeln!(printer.stderr(), "{}", no_tools_installed_msg)?; return Ok(ExitStatus::Success); } + writeln!( + printer.stdout(), + "Provide a command to invoke with `uvx ` or `uvx --from `.\n\n\ + The following tools are already installed:\n" + )?; + for (name, tool) in tools { // Skip invalid tools let Ok(tool) = tool else { @@ -69,7 +76,6 @@ pub(crate) async fn list( String::new() }; - writeln!(printer.stdout(), "Installed tools:\n")?; if show_paths { writeln!( printer.stdout(), @@ -100,5 +106,6 @@ pub(crate) async fn list( } } + writeln!(printer.stdout(), "\nSee `uvx --help` for more information.")?; Ok(ExitStatus::Success) } diff --git a/crates/uv/tests/tool_list.rs b/crates/uv/tests/tool_list.rs index 645e30052ff9c..ac4f427009b05 100644 --- a/crates/uv/tests/tool_list.rs +++ b/crates/uv/tests/tool_list.rs @@ -30,12 +30,16 @@ fn tool_list() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: black v24.2.0 - black - blackd + See `uvx --help` for more information. + ----- stderr ----- "###); } @@ -61,12 +65,16 @@ fn tool_list_paths() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: black v24.2.0 ([TEMP_DIR]/tools/black) - black ([TEMP_DIR]/bin/black) - blackd ([TEMP_DIR]/bin/blackd) + See `uvx --help` for more information. + ----- stderr ----- "###); } @@ -85,7 +93,9 @@ fn tool_list_empty() { ----- stdout ----- ----- stderr ----- - No tools installed + No tools installed. + + See `uv tool install --help` for more information. "###); } @@ -112,6 +122,12 @@ fn tool_list_missing_receipt() { success: true exit_code: 0 ----- stdout ----- + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: + + + See `uvx --help` for more information. ----- stderr ----- warning: Ignoring malformed tool `black` (run `uv tool uninstall black` to remove) @@ -159,11 +175,15 @@ fn tool_list_bad_environment() -> Result<()> { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: ruff v0.3.4 - ruff + See `uvx --help` for more information. + ----- stderr ----- Invalid environment at `tools/black`: missing Python executable at `tools/black/[BIN]/python` "### @@ -224,12 +244,16 @@ fn tool_list_deprecated() -> Result<()> { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: black v24.2.0 - black - blackd + See `uvx --help` for more information. + ----- stderr ----- "###); @@ -253,6 +277,12 @@ fn tool_list_deprecated() -> Result<()> { success: true exit_code: 0 ----- stdout ----- + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: + + + See `uvx --help` for more information. ----- stderr ----- warning: Ignoring malformed tool `black` (run `uv tool uninstall black` to remove) @@ -282,12 +312,16 @@ fn tool_list_show_version_specifiers() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: black v24.2.0 [required: <24.3.0] - black - blackd + See `uvx --help` for more information. + ----- stderr ----- "###); @@ -298,12 +332,16 @@ fn tool_list_show_version_specifiers() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: black v24.2.0 [required: <24.3.0] ([TEMP_DIR]/tools/black) - black ([TEMP_DIR]/bin/black) - blackd ([TEMP_DIR]/bin/blackd) + See `uvx --help` for more information. + ----- stderr ----- "###); } diff --git a/crates/uv/tests/tool_run.rs b/crates/uv/tests/tool_run.rs index 2c98d45d21bf6..07f089859ff2e 100644 --- a/crates/uv/tests/tool_run.rs +++ b/crates/uv/tests/tool_run.rs @@ -755,7 +755,9 @@ fn tool_run_list_installed() { ----- stdout ----- ----- stderr ----- - No tools installed + No tools installed. + + See `uv tool install --help` for more information. "###); // Install `black`. @@ -774,12 +776,16 @@ fn tool_run_list_installed() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a command to invoke with `uvx ` or `uvx --from `. + + The following tools are already installed: black v24.2.0 - black - blackd + See `uvx --help` for more information. + ----- stderr ----- "###); } diff --git a/crates/uv/tests/tool_uninstall.rs b/crates/uv/tests/tool_uninstall.rs index 9a9a3e7fb31a8..36013128db5b3 100644 --- a/crates/uv/tests/tool_uninstall.rs +++ b/crates/uv/tests/tool_uninstall.rs @@ -42,7 +42,9 @@ fn tool_uninstall() { ----- stdout ----- ----- stderr ----- - No tools installed + No tools installed. + + See `uv tool install --help` for more information. "###); // After uninstalling the tool, we should be able to reinstall it. @@ -111,7 +113,9 @@ fn tool_uninstall_multiple_names() { ----- stdout ----- ----- stderr ----- - No tools installed + No tools installed. + + See `uv tool install --help` for more information. "###); }