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

Shadowing command with alias as a default configuration #8360

Closed
woshilapin opened this issue Jun 15, 2020 · 2 comments
Closed

Shadowing command with alias as a default configuration #8360

woshilapin opened this issue Jun 15, 2020 · 2 comments
Assignees
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

@woshilapin
Copy link

woshilapin commented Jun 15, 2020

Describe the problem you are trying to solve
I often run the same commands over and over with the same set of flags (--all-features, --all-targets, --deny warnings). Then I found out about the .cargo/config and the [alias] section. So I thought about doing a recursive alias (like I would do with aliases in a shell).

[alias]
clippy = "clippy --workspace --all-features --all-targets -- --deny warnings"

But this is not possible as it is shadowing the existing clippy command. Actually, it might even be a bug because this is what I get when I'm trying to do that.

$> cargo clippy

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
[1]    2198266 abort (core dumped)  cargo clippy

Describe the solution you'd like
Like aliases in a shell, I'd expect the alias defined above to just work when typing cargo clippy.

One nice advantage would be that all the project's contributors would follow the same configuration for the project (including the CI).

Notes
I'm throwing the idea but I'm also aware of the weirdness in a recursive definition. It might not be desirable.

Another possible drawback: it might be harder to use the original clippy command. For example, in shell, if we had an alias ls="ls -l", we could use the original command (and therefore deactivate the -l option) by doing /usr/bin/ls. Not sure how to reproduce a similar behavior with cargo.

Related issues
#2901

@woshilapin woshilapin added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jun 15, 2020
@ehuss ehuss added the A-aliases Area: command aliases label Jun 25, 2020
@nipunn1313
Copy link
Contributor

@rustbot claim

nipunn1313 added a commit to nipunn1313/cargo that referenced this issue Aug 16, 2021
Teaches cargo to accept default-args aliases of the form
[alias]
fmt = fmt --verbose

Disallows this on builtins.

Fixes rust-lang#8360
@ehuss
Copy link
Contributor

ehuss commented Aug 18, 2021

Closing this as resolved by #9791.

@ehuss ehuss closed this as completed Aug 18, 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

Successfully merging a pull request may close this issue.

3 participants