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

Provide a CLI option to run cargo commands from the root of a workspace #9123

Open
sunshowers opened this issue Feb 2, 2021 · 0 comments
Open
Labels
A-cli Area: Command-line interface, option parsing, etc. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@sunshowers
Copy link
Contributor

sunshowers commented Feb 2, 2021

Describe the problem you are trying to solve
I'd like to define a Cargo alias which encodes a file path that's relative to the root of the workspace. Currently, there appears to be no way to define a Cargo alias that works from any subdirectory, because:

  • aliases run from the cwd, not the root (which makes sense)
  • you can't run, e.g. cd (or multiple commands in general) in a Cargo alias

Describe the solution you'd like

A new global flag to cargo, e.g. --root-cwd, which runs the command and interprets paths relative to the root of the workspace. (It can be defined to be equivalent to cd $WORKSPACE_ROOT && cargo <command>....)

This may also be paired with a --cwd option which runs the command and interprets paths relative to the given cwd. (Again, cargo --cwd CWD <command>... can be defined to be equivalent to cd $CWD && cargo <command>....)

Notes

Some prior art: Mercurial has the --cwd flag which has this behavior: https://www.mercurial-scm.org/doc/hg.1.html#options. Not sure about Git.

@sunshowers sunshowers added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Feb 2, 2021
@ehuss ehuss added the A-cli Area: Command-line interface, option parsing, etc. label Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. 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