Provide a CLI option to run cargo commands from the root of a workspace #9123
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`
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:
cd
(or multiple commands in general) in a Cargo aliasDescribe 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 tocd $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 tocd $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.The text was updated successfully, but these errors were encountered: