summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-03-29 01:51:08 +0100
committermo8it <mo8it@proton.me>2024-03-29 01:51:08 +0100
commita561a0f7f0378ac98ee4f025f5023c320af794b8 (patch)
tree614640157546b61594984fefc188cacb11cabd50
parent36a8e3ac0ee4f59ed587725e3257a79129a981e2 (diff)
Avoid reinitialization by mistake
-rw-r--r--src/init.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/init.rs b/src/init.rs
index 6653535..e640c25 100644
--- a/src/init.rs
+++ b/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 {