From f1c206c8a730fe881c87179834c5b96bd6e16eb3 Mon Sep 17 00:00:00 2001 From: Ahmed Ilyas Date: Tue, 22 Oct 2024 20:15:32 +0200 Subject: [PATCH] Suggest `--from` command when executable is available for `uvx`/`uv tool run` --- crates/uv/src/commands/tool/run.rs | 9 +++++++++ crates/uv/tests/it/tool_run.rs | 2 ++ 2 files changed, 11 insertions(+) diff --git a/crates/uv/src/commands/tool/run.rs b/crates/uv/src/commands/tool/run.rs index d43f2f85210b..33d31697724f 100644 --- a/crates/uv/src/commands/tool/run.rs +++ b/crates/uv/src/commands/tool/run.rs @@ -207,6 +207,15 @@ pub(crate) async fn run( for (name, _) in entrypoints { writeln!(printer.stdout(), "- {}", name.cyan())?; } + let suggested_command = format!( + "{} --from {} ", + invocation_source, from.name + ); + writeln!( + printer.stdout(), + "Consider using `{}` instead.", + suggested_command.green() + )?; } return Ok(ExitStatus::Failure); } diff --git a/crates/uv/tests/it/tool_run.rs b/crates/uv/tests/it/tool_run.rs index f8365caa2f44..7426a4ebc850 100644 --- a/crates/uv/tests/it/tool_run.rs +++ b/crates/uv/tests/it/tool_run.rs @@ -141,6 +141,7 @@ fn tool_run_at_version() { The following executables are provided by `pytest`: - py.test - pytest + Consider using `uv tool run --from pytest ` instead. ----- stderr ----- Resolved 4 packages in [TIME] @@ -202,6 +203,7 @@ fn tool_run_suggest_valid_commands() { The following executables are provided by `black`: - black - blackd + Consider using `uv tool run --from black ` instead. ----- stderr ----- Resolved 6 packages in [TIME]