-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Cargo new in empty dir #2008
Cargo new in empty dir #2008
Conversation
Allows "new" command even if path exists, if the path is empty or almost empty directory. Also more narrow duplicates: rust-lang#1990, rust-lang#1065, rust-lang#526.
The test was testing that "cargo new" fails when the directory already exists. Now it also creates a file in this directory. There should be more tests for this, this is a quick fix.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -45,9 +45,41 @@ struct CargoNewConfig { | |||
version_control: Option<VersionControl>, | |||
} | |||
|
|||
fn can_we_use_this_path_for_a_new_project (path: &Path) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love this fn name
🎊 i am excited to have this |
I don't understand the failure from Travis-CI. |
Thanks for the PR @vi! The intention right now is to have The |
@alexcrichton, The only explicit Is implementing a preliminary "init" command without too involved logic (i.e. not trying to do VCS things) a good idea? Just to stop annoyance and pump down tension. |
Although this is just "new in a directory with only VCS files" I feel that it's similar enough to |
@alexcrichton, What are requirements for a "fully feldged |
I think it'd be fine to implement without an RFC, and discussion can probably happen on the PR as well. I'd expect pieces along the lines of:
It doesn't have to be too too complete to start off I think (it'll have room to grow). |
Is the following for initial implementation of
|
I would personally prefer a more feature-ful implementation along the lines of "I just created this structure but forgot |
@alexcrichton, Do you approve this algorithm for |
Yeah that looks pretty good to me! I'd probably avoid actually moving files and instead just generate a |
Closing in favor of #2081 |
Implement `cargo init` command and appropriate tests ( #21). Features: * Working like `cargo new` if there are no files in current directory * Auto-detection of `--bin` * Auto-detection of already existing VSC and appending to respecive ignore file * Appending of appropriate `[lib]` or `[[bin]]` section to `Cargo.toml` in case of some non-standard source locations Concerns: * I'm not experienced in Rust + lazy => code looks poorer compared to the rest Cargo code * The test don't cover 100% of functions * Project consisting of both binary and library is not handled * Many deviations from [previously proposed algorithm](#2008 (comment))
cargo new .
. It checks if directory is empty (or contains only VCS-related files)cargo init
suggestnew .
instead of justnew