From dcf1254062f40cb71663dc31f638ce1f7d0b5505 Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Mon, 23 Sep 2024 21:56:21 +0200 Subject: [PATCH] Make the context message more informative Signed-off-by: Kemal Akkoyun --- crates/uv/src/commands/tool/list.rs | 18 ++++++-- crates/uv/tests/tool_list.rs | 72 +++++++++++++++++++---------- crates/uv/tests/tool_run.rs | 14 ++++-- 3 files changed, 70 insertions(+), 34 deletions(-) diff --git a/crates/uv/src/commands/tool/list.rs b/crates/uv/src/commands/tool/list.rs index efe57f9e10dde..7648e5fd4c6cf 100644 --- a/crates/uv/src/commands/tool/list.rs +++ b/crates/uv/src/commands/tool/list.rs @@ -69,18 +69,26 @@ pub(crate) async fn list( String::new() }; - writeln!(printer.stdout(), "Installed tools:\n")?; + writeln!( + printer.stdout(), + "Provide a tool to invoke with `uvx `.\n\ + e.g. `uvx ruff`\n\ + If the tool provides multiple executables, you can use `uvx --from `.\n\ + e.g. `uvx --from black blackd`\n\ + The following tools (and executables) are already installed:\n\ + " + )?; if show_paths { writeln!( printer.stdout(), - "{} ({})", + "- {} ({})", format!("{name} v{version}{version_specifier}").bold(), installed_tools.tool_dir(&name).simplified_display().cyan(), )?; } else { writeln!( printer.stdout(), - "{}", + "- {}", format!("{name} v{version}{version_specifier}").bold() )?; } @@ -90,12 +98,12 @@ pub(crate) async fn list( if show_paths { writeln!( printer.stdout(), - "- {} ({})", + " * {} ({})", entrypoint.name, entrypoint.install_path.simplified_display().cyan() )?; } else { - writeln!(printer.stdout(), "- {}", entrypoint.name)?; + writeln!(printer.stdout(), " * {}", entrypoint.name)?; } } } diff --git a/crates/uv/tests/tool_list.rs b/crates/uv/tests/tool_list.rs index 645e30052ff9c..024d8110de0df 100644 --- a/crates/uv/tests/tool_list.rs +++ b/crates/uv/tests/tool_list.rs @@ -30,11 +30,15 @@ fn tool_list() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a tool to invoke with `uvx `. + e.g. `uvx ruff` + If the tool provides multiple executables, you can use `uvx --from `. + e.g. `uvx --from black blackd` + The following tools (and executables) are already installed: - black v24.2.0 - - black - - blackd + - black v24.2.0 + * black + * blackd ----- stderr ----- "###); @@ -61,11 +65,15 @@ fn tool_list_paths() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a tool to invoke with `uvx `. + e.g. `uvx ruff` + If the tool provides multiple executables, you can use `uvx --from `. + e.g. `uvx --from black blackd` + The following tools (and executables) are already installed: - black v24.2.0 ([TEMP_DIR]/tools/black) - - black ([TEMP_DIR]/bin/black) - - blackd ([TEMP_DIR]/bin/blackd) + - black v24.2.0 ([TEMP_DIR]/tools/black) + * black ([TEMP_DIR]/bin/black) + * blackd ([TEMP_DIR]/bin/blackd) ----- stderr ----- "###); @@ -159,10 +167,14 @@ fn tool_list_bad_environment() -> Result<()> { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a tool to invoke with `uvx `. + e.g. `uvx ruff` + If the tool provides multiple executables, you can use `uvx --from `. + e.g. `uvx --from black blackd` + The following tools (and executables) are already installed: - ruff v0.3.4 - - ruff + - ruff v0.3.4 + * ruff ----- stderr ----- Invalid environment at `tools/black`: missing Python executable at `tools/black/[BIN]/python` @@ -224,11 +236,15 @@ fn tool_list_deprecated() -> Result<()> { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a tool to invoke with `uvx `. + e.g. `uvx ruff` + If the tool provides multiple executables, you can use `uvx --from `. + e.g. `uvx --from black blackd` + The following tools (and executables) are already installed: - black v24.2.0 - - black - - blackd + - black v24.2.0 + * black + * blackd ----- stderr ----- "###); @@ -282,11 +298,15 @@ fn tool_list_show_version_specifiers() { success: true exit_code: 0 ----- stdout ----- - Installed tools: + Provide a tool to invoke with `uvx `. + e.g. `uvx ruff` + If the tool provides multiple executables, you can use `uvx --from `. + e.g. `uvx --from black blackd` + The following tools (and executables) are already installed: - black v24.2.0 [required: <24.3.0] - - black - - blackd + - black v24.2.0 [required: <24.3.0] + * black + * blackd ----- stderr ----- "###); @@ -298,11 +318,15 @@ fn tool_list_show_version_specifiers() { success: true exit_code: 0 ----- stdout ----- - Installed tools: - - black v24.2.0 [required: <24.3.0] ([TEMP_DIR]/tools/black) - - black ([TEMP_DIR]/bin/black) - - blackd ([TEMP_DIR]/bin/blackd) + Provide a tool to invoke with `uvx `. + e.g. `uvx ruff` + If the tool provides multiple executables, you can use `uvx --from `. + e.g. `uvx --from black blackd` + The following tools (and executables) 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) ----- stderr ----- "###); diff --git a/crates/uv/tests/tool_run.rs b/crates/uv/tests/tool_run.rs index 2c98d45d21bf6..fcca87373bbbf 100644 --- a/crates/uv/tests/tool_run.rs +++ b/crates/uv/tests/tool_run.rs @@ -774,11 +774,15 @@ fn tool_run_list_installed() { success: true exit_code: 0 ----- stdout ----- - Installed tools: - - black v24.2.0 - - black - - blackd + Provide a tool to invoke with `uvx `. + e.g. `uvx ruff` + If the tool provides multiple executables, you can use `uvx --from `. + e.g. `uvx --from black blackd` + The following tools (and executables) are already installed: + + - black v24.2.0 + * black + * blackd ----- stderr ----- "###);