Skip to content

Support cargo new/init --force #6708

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

Closed
wants to merge 4 commits into from
Closed

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Mar 2, 2019

Fixes #3832

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

I haven't really personally given any thought to this and that's quite an old bug, @dwijnand mind expanding a bit on what this is doing? Could you document a bit the new semantics, how it works, and how it's intended to be used?

@dwijnand
Copy link
Member Author

dwijnand commented Mar 5, 2019

Sure!

So right now there are two fast-fail checks in cargo new and cargo init (fs::metadata(<target dir>).is_ok() and fs::metadata(&<cwd>.join("Cargo.toml")).is_ok(), respectively) and all this patch is suggesting is to add a --force flag (much like cargo has for install) to override this check.

I added two tests that assert that calling cargo new --force against a directory that already exists exits without failure, and calling cargo init --force inside an already initialised crate exits without failure.

The intention, as captured by #3832 and that I share, is to be able to re-initialise a crate when one is created or initialised with the wrong crate type (bin/lib). I've almost got my muscle memory well-trained, but I suggesting with this patch that this be possible out-the-box.

(I'm fine with this being rejected, no hurt feelings.)

@dwijnand
Copy link
Member Author

dwijnand commented Mar 8, 2019

Maybe this isn't worth the brain cycles.

@dwijnand dwijnand closed this Mar 8, 2019
@dwijnand dwijnand deleted the init-force branch March 8, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants