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 cargo new --workspace to create a workspace #8365

Open
camelid opened this issue Jun 16, 2020 · 11 comments
Open

Add cargo new --workspace to create a workspace #8365

camelid opened this issue Jun 16, 2020 · 11 comments
Labels
A-workspaces Area: workspaces C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-new S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@camelid
Copy link
Member

camelid commented Jun 16, 2020

Describe the problem you are trying to solve

One has to manually create a new directory and setup a Cargo.toml, rather than being able to simply run cargo new foo --workspace and have a basic template set-up.

Describe the solution you'd like

Add the option --workspace to cargo new that creates a new workspace with the provided name.

Notes

The feature is not too important, but it seems like it would streamline the process of creating a new workspace a bit.

For general template support, see #5151

For adding workspace members to a workspace, see #6378

@camelid camelid added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jun 16, 2020
@ehuss ehuss added A-workspaces Area: workspaces Command-new labels Jun 25, 2020
@pksunkara
Copy link

Just wanted to chime in and say that we have been looking to implement this with pksunkara/cargo-workspaces#15. Once that PR is merged, you should be able to do cargo ws init.

@buzmeg
Copy link

buzmeg commented Apr 4, 2021

Should this also be closed as postponed per #8411 ?

@Stargateur
Copy link

@buzmeg why is there another issue that ask about this feature ?

@H2rmone
Copy link

H2rmone commented Nov 11, 2021

Same confusion here. In Javascript community, tools like lerna, yarn workspace and nx both have command to create workspace project. Cargo workspace includes many feature, I think it will save a lot of beginners' time if we have command to create workspace project like cargo new --workspace.

@dobromyslov
Copy link

Are there any plans to implement this feature? Looks like the templates feature was postponed last year.

@drebbe-intrepid
Copy link

Any update with this? I would love this feature also.

@epage epage changed the title Add cargo new --workspace Add cargo new --workspace to create a workspace May 30, 2023
@epage epage added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label May 30, 2023
@epage
Copy link
Contributor

epage commented May 30, 2023

I've clarified the title and linked out to #6378 since I always get these mixed up.

As for plans to move forward with this, someone would need to step up and work on a design for this which at least acknowledges the needs of #6378 so one doesn't block the other.

My gut feeling is there are enough use cases with various needs that we'd be better served by research into #5151.

@BartMassey
Copy link
Contributor

I will admit to typing cargo init --workspace in a directory containing a bunch of project directories just now and expecting it to "just work", adding all the project directories as workspace members. It would be great if this is possible, as its current omission violates the principle of least surprise a bit I think.

Ah well, off to handwrite a workspace Cargo.toml.

@rosti-il
Copy link

I think it's worth to support the --workspace option not only in cargo new and cargo init but also in cargo remove.

@epage
Copy link
Contributor

epage commented Jun 29, 2024

cargo remove automatically removes workspace dependencies when they are no longer used.

@rosti-il
Copy link

@epage you're right. I just got confused between cargo new and cargo add when thought about the opposite of cargo remove.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-workspaces Area: workspaces C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-new S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests