-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
improve error message for no such subcommand
#10924
Conversation
…tation; very basic and not final
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Based on my different pieces of feedback, here is a rough sketch of how I think this should behave if cmd.starts_with('+') {
anyhow::format_err!("no such subcommand: `{}`{}\n\n\tCargo does not handle `+toolchain` directives itself.\n\tDid you mean to run `cargo` through `rustup` instead?", cmd, did_you_mean)
} else {
let suggestions = list_commands(config);
let did_you_mean = closest_msg(cmd, suggestions.keys(), |c| c);
anyhow::format_err!("no such subcommand: `{}`{}\nView all installed commands with `cargo --list`", cmd, did_you_mean)
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few places where this update is not being checked. It might be good to update a few of the tests from with_stderr_contains
to use with_stderr
i.e.
.with_stderr(
"\
error: no such subcommand: `C`
<tab>Did you mean `c`?
<tab>View all installed commands with `cargo --list`
",
)
@epage do you have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good.
Probably only thing remaining is ensuring the message for +
and suggestions looks good.
…er-no-such-subcommand
Thank you. But, I am a bit confused on what you mean by "ensuring the message for |
Testing the case for |
ah ok. Would I write the test for this in the |
Seems like a good place |
…er-no-such-subcommand
… message stating that the directive is not handled by Cargo
@bors r+ Thanks for all your work on this! |
No problem! Looking forward to making more contributions to Rust repositories. |
☀️ Test successful - checks-actions |
Update cargo 7 commits in 4fd148c47e733770c537efac5220744945d572ef..ce40690a5e4e315d3dab0aae1eae69d0252c52ac 2022-08-03 15:03:52 +0000 to 2022-08-09 22:32:17 +0000 - Make the `rust-version` error recommend `cargo update --precise -p crate@ver` (rust-lang/cargo#10891) - resolver docs: link to version requirements syntax full explanation (rust-lang/cargo#10946) - Bump os_info to 3.5.0 (rust-lang/cargo#10943) - Mark --timings=html unstable in the document (rust-lang/cargo#10941) - Mention that aliases are recursive (rust-lang/cargo#10935) - Test if reserved filenames are allowed in Windows (rust-lang/cargo#10322) - improve error message for `no such subcommand` (rust-lang/cargo#10924)
Closes #10900