Skip to content
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

cargo help <alias> should show what <alias> stands for #10138

Closed
poliorcetics opened this issue Nov 30, 2021 · 0 comments
Closed

cargo help <alias> should show what <alias> stands for #10138

poliorcetics opened this issue Nov 30, 2021 · 0 comments
Labels
A-aliases Area: command aliases C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@poliorcetics
Copy link
Contributor

Problem

Currently, if I have a .cargo/config like this:

[alias]
bw = "build --target x86_64-pc-windows-msvc --release"
bl = "build --target x86_64-unknown-linux-musl --release"

And I do cargo help bw

I get the help for cargo build

Proposed Solution

Instead of the current behavior, I would like something like git:

$ git help c
'c' is aliased to 'commit'

$ git help cam
'cam' is aliased to 'commit --amend -m'

If I want the infos for build, cargo bw --help would still work, just like git cam --help show the full help for commit in the example above.

Notes

One thing I have not seen git do is tell from where the alias comes. If possible, indicating the file (and even the precise location) would be very nice.

The same could be done for subcommands like cargo add from cargo-edit, with something like this:

$ cargo help add
`cargo add` comes from `$CARGo_HOME/bin/cargo-add`

But this could be a separate feature request, I don't know how much the two are linked internally.

@poliorcetics poliorcetics added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Nov 30, 2021
@ehuss ehuss added the A-aliases Area: command aliases label Dec 6, 2021
bors added a commit that referenced this issue Dec 14, 2021
Display alias target on 'cargo help <alias>`

```
Previously, `cargo help <alias>` resolved the alias and displayed the
help for the targeted subcommand. For example, if `br` were aliased to
`build --release`, `cargo help br` would display the manpage for
cargo-build.

With this patch, it will print "'br' is aliased to 'build --release'".
```

Addresses issue #10138.

This is my first patch to Cargo. I attempted to follow the style of the surrounding code. Please let me know if any changes are required: happy to make them. In particular, I wasn't sure if any tests exist for this path.
@bors bors closed this as completed in 7084570 Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-aliases Area: command aliases C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

2 participants