mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 14:57:32 -05:00
Avoid reinitialization by mistake
This commit is contained in:
parent
36a8e3ac0e
commit
a561a0f7f0
1 changed files with 10 additions and 0 deletions
10
src/init.rs
10
src/init.rs
|
@ -45,6 +45,16 @@ fn create_vscode_dir() -> Result<()> {
|
|||
}
|
||||
|
||||
pub fn init_rustlings(exercises: &[Exercise]) -> Result<()> {
|
||||
if Path::new("exercises").is_dir() && Path::new("Cargo.toml").is_file() {
|
||||
bail!(
|
||||
"A directory with the name `exercises` and a file with the name `Cargo.toml` already exist
|
||||
in the current directory. It looks like Rustlings was already initialized here.
|
||||
Run `rustlings` for instructions on getting started with the exercises.
|
||||
|
||||
If you didn't already initialize Rustlings, please initialize it in another directory."
|
||||
);
|
||||
}
|
||||
|
||||
let rustlings_path = Path::new("rustlings");
|
||||
if let Err(e) = create_dir(rustlings_path) {
|
||||
if e.kind() == ErrorKind::AlreadyExists {
|
||||
|
|
Loading…
Reference in a new issue