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

Add --workspace to cargo add #13915

Closed
jmg-duarte opened this issue May 15, 2024 · 3 comments
Closed

Add --workspace to cargo add #13915

jmg-duarte opened this issue May 15, 2024 · 3 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@jmg-duarte
Copy link

jmg-duarte commented May 15, 2024

Problem

I am working on a project where we're placing all dependencies in the workspace. Whenever I add a new dependency I want to be able to add it to the workspace rather than the local Cargo.toml file.

Proposed Solution

The command

cargo add tokio -F full --workspace

Should add tokio to the the current Cargo.toml like so:

[dependencies]
tokio = { workspace = true, features = ["full"] }

And to the workspace Cargo.toml:

[dependencies]
tokio = "1" # or whatever version it would add

To find the workspace file, the command would go up the directories looking for Cargo.toml where members contains the current package.

Additionally, the --workspace flag could take a parameter with the workspace Cargo.toml's path.

Notes

If the feature is to be implemented, I am available to do it!

@jmg-duarte jmg-duarte added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels May 15, 2024
@weihanglo
Copy link
Member

Thanks for the proposal. This is probably a duplicate of #10608?

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. S-triage Status: This issue is waiting on initial triage. and removed S-triage Status: This issue is waiting on initial triage. S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. labels May 15, 2024
@jmg-duarte
Copy link
Author

This is probably a duplicate of #10608?

Yes and no 😅 the ideas are clearly siblings but the interface I was looking for is not the same as the one proposed on that issue.

I feel that my interface is much more clear cut than those discussed there. It's clear where you're adding by default (the current package) and the flag makes it explicit where it goes to.

But let me know if I should move this discussion there!

@weihanglo
Copy link
Member

Thanks for the clarification! Yeah the design space is quite the same, so better discussing the needs and alternatives altogether :)

Closing this and feel free to drop ideas there.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants