Skip to content

Automated way to create an alias for cargo subcommand? #9061

Open
@k0pernicus

Description

@k0pernicus

Describe the problem you are trying to solve

I am trying to create an alias for cargo-generate.
The crate cargo-generate is automatically used when executing cargo generate.
With the help of structopt, we created an alias called gen to execute cargo-generate using cargo run -- gen instead of cargo run -- generate.

After installing the crate locally (cargo install --path .), the current way to execute cargo generate is to let cargo make an invocation of an external tool cargo-${command}, so cargo gen is an unknown command to cargo.

Describe the solution you'd like

A solution to create aliases is to generate a file called config inside $HOME/.cargo, and fill it with an alias, like this:

[alias]
gen = "generate"

but this method needs a manual intervention from the user.

I would like to know if it exists an "automated" way to create this alias easily after installing the crate on a system, or not.

Notes

Original issue, posted in cargo-generate, here.

Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-aliasesArea: command aliasesA-new-subcommandArea: new subcommandC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-installS-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions