-
Notifications
You must be signed in to change notification settings - Fork 3k
Add hint for misplaced --verbose in uv tool run
#17020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
ea6da01
b5b2fa9
fff00c1
8526719
4c4ee23
f968526
720e074
73691ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,21 @@ impl Display for ToolRunCommand { | |
| } | ||
| } | ||
|
|
||
| fn find_verbose_flag(args: &[std::ffi::OsString]) -> Option<&str> { | ||
| for arg in args { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I might write this using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactored to use |
||
| if let Some(arg_str) = arg.to_str() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I might use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used |
||
| if arg_str == "--verbose" { | ||
| return Some("--verbose"); | ||
| } | ||
| // Match -v, -vv, -vvv, etc. (but not other flags starting with -v like -version) | ||
| if arg_str.starts_with("-v") && arg_str.chars().skip(1).all(|c| c == 'v') { | ||
| return Some(arg_str); | ||
| } | ||
| } | ||
| } | ||
| None | ||
| } | ||
|
|
||
| /// Run a command. | ||
| #[allow(clippy::fn_params_excessive_bools)] | ||
| pub(crate) async fn run( | ||
|
|
@@ -309,11 +324,24 @@ pub(crate) async fn run( | |
| .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); | ||
| } | ||
|
|
||
| return diagnostics::OperationDiagnostic::native_tls(client_builder.is_native_tls()) | ||
| .with_context("tool") | ||
| let diagnostic = | ||
| diagnostics::OperationDiagnostic::native_tls(client_builder.is_native_tls()); | ||
| let diagnostic = if let Some(verbose_flag) = find_verbose_flag(args) { | ||
| diagnostic.with_hint(format!( | ||
| "You provided `{}` to `{}`. Did you mean to provide it to `{}`? e.g., `{}`", | ||
| verbose_flag.cyan(), | ||
| target.cyan(), | ||
| invocation_source.to_string().cyan(), | ||
| format!("{invocation_source} {verbose_flag} {target}").green() | ||
| )) | ||
|
EliteTK marked this conversation as resolved.
|
||
| } else { | ||
| diagnostic.with_context("tool") | ||
| }; | ||
| return diagnostic | ||
| .report(err) | ||
| .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); | ||
| } | ||
|
|
||
| Err(ProjectError::Requirements(err)) => { | ||
| let err = miette::Report::msg(format!("{err}")) | ||
| .context("Failed to resolve `--with` requirement"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.