workspace dependency options for cargo add
#11527
Labels
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Problem
cargo add
, although an already extensive command, currently doesn't have support for easily adding dependencies to[workspace.dependencies]
or for specifying that a dependency should be workspace-inherited. This issue proposes an option for both of these use cases.Proposed Solution
Adding to
[workspace.dependencies]
Adding to the
[workspace.dependencies]
section could be done through a--workspace
option. Chapter 3.3 of the Cargo Book, under The dependencies table section, states that:This would mean that the
--workspace
option would have to be mutually exclusive with the--optional
option.Adding workspace-inherited dependencies
Workspace-inherited dependencies could be added through a
--workspace-inherited
option. Chapter 3.1 of the Cargo Book, under the Inheriting a dependency from a workspace section, states that:This would mean that the
--workspace-inherited
option would have to be mutually exclusive with all of the Source options, and all of the Dependency options besides--optional
,--no-optional
,--default-features
(since it doesn't add to the dependency keys),--features
, and--dry-run
.The
--workspace-inherited
option would just addcrate_name.workspace = true
to the desired dependencies section orcrate_name = { workspace = true, ... }
if--optional
and/or--features
were specified.Notes
No response
The text was updated successfully, but these errors were encountered: