Skip to content

Shorthand for --manifest-path #16726

@bushrat011899

Description

@bushrat011899

Problem

When experimenting with Cargo scripts (see #12207), it's expected that a user will need to specify the script using --manifest-path for the various applicable cargo subcommands (add, fix, etc.). This is quite verbose, for example:

cargo fix --manifest-path foo.rs 

While this is most noticeable with scripts, the verbosity is still applicable outside that context. As such, I believe this issue can be examined independently.

Proposed Solution

I believe -m or -M would be an appropriate shorthand to add to the applicable subcommands, as an example:

cargo fix -m foo.rs

I've made commit here which adds the shorthand and tests to ensure the shorthand works as expected across all commands that currently have a --manifest-path flag. Notably missing is updates to relevant documentation, as this is my first attempt at working on Cargo and I'm not totally sure what the recommended way to update it would be.

Notes

  • Looking at src\etc\cargo.bashcomp.sh, only --manifest-path and --message-format begin with the letter m out of all possible flags across all commands. Since --message-format is only applicable in 3 commands, while --manifest-path is applicable in 22, I'd argue the chance for ambiguity is very low.
  • While --jobs has a shorthand of -j, --features instead uses -F. I'm not sure what (if any) pattern is used to choose lowercase vs capital shorthands, so I elected to use -m in the above example arbitrarily.
  • I searched through previous issues and pull-requests and couldn't find any similar requests for a --manifest-path shorthand, but please let me know if there is one I missed!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cliArea: Command-line interface, option parsing, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewZ-scriptNightly: cargo script

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions