Skip to content

Extend aliases: allow arbitrary commands #6575

Open
@theduke

Description

@theduke

The [alias] configuration is very useful.

It would be even more useful if there was a way to not only define aliases for cargo, but to run arbitrary scripts.
It's a shame that alias doesn't allow this already.
I'm therefore proposing to add a new feature: scripts.

I'm imagining something like how npm works, where you can define arbitrary scripts in package.json that can be executed with npm NAME or npm run NAME (for conflicts).
This is very widely used in the JS ecosystem and a great convenience utility.

It would allow a unified way to execute project-related convenience scripts, etc.

EG:

.cargo/config:

[script]
generate-keys = "ssh-keygen ....."
check = "cargo fmt && cargo test && cargo clippy"
deploy = "./bin/deploy.sh"
# Conflicting name, see below
publish = "./bin/publish.sh"
...

Disambiguation could be enabled by the cargo script command, eg : cargo script publish && cargo deploy.

Scripts would have the lowest priority, after built in commands, aliases and external binaries.
I'd prefer them to have higher priority than global aliases and extension binaries, but that would be backwards incompatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-aliasesArea: command aliasesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions