cargo
cargo copied to clipboard
Show description for user-installed binaries when running "cargo --list"
What does this PR try to resolve?
I've noticed that when running cargo --list, user-installed subcommands wouldn't have a description. In order to resolve this, cargo will now communicate with the crates.io registry (if those packages were installed from crates.io ofc) and retrieve the package description from there. This also works if the binary name is different than the name of the package (for example, if a package installs multiple binaries)
How should we test and review this PR?
I've noticed that some test use the --list flag, so if they pass, this should be fine
Additional information
crates.io allows someone to go to https://crates.io/api/v1/crates/{crate} and get info about this crate in a JSON format. However, from what I've found, this isn't standardized for other Rust registries, and so, if a subcommand was installed from another registry, it won't print a description. Please verify that this is the case. If not, I can remove the relevant checks for other registries.
IMPORTANT
I haven't fixed the relevant tests yet, so DON'T merge this immediately
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) some time within the next two weeks.
Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:
@rustbot author: the review is finished, PR author should check the comments and take action accordingly@rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
I might have found why those tests are failing. For some reason, by making those changes to the code, cargo --list now generates trailing whitespaces on every end of line of subcommands without a description, even though I couldn't narrow down why this happens. Any help would be appreciated
I am not going to discuss any specific implementation further until we have a conclusion on the design. Could we bring it back to https://github.com/rust-lang/cargo/issues/10662, and gather ideas there?
I'm going to close per the comment about about not having a chosen design, yet. Additionally, I don't think we will want to do network requests in the --list command. Thanks for the contribution, though!