From 82ebd29ff603b1f62c4e17f0f0c85cfcf05e70a0 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 9 Aug 2024 01:14:08 +0200 Subject: [PATCH] Add a special confirmation for initialization in a workspace --- src/init.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/init.rs b/src/init.rs index 62a670db..5e876d62 100644 --- a/src/init.rs +++ b/src/init.rs @@ -57,6 +57,9 @@ pub fn init() -> Result<()> { bail!("The current directory is already part of a Cargo project.\nPlease initialize Rustlings in a different directory"); } + stdout.write_all(b"This command will create the directory `rustlings/` as a member of this Cargo workspace.\nPress ENTER to continue ")?; + press_enter_prompt(&mut stdout)?; + // Make sure "rustlings" is added to `workspace.members` by making // Cargo initialize a new project. let status = Command::new("cargo") @@ -76,11 +79,11 @@ pub fn init() -> Result<()> { fs::remove_dir_all("rustlings") .context("Failed to remove the temporary directory `rustlings/`")?; init_git = false; + } else { + stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?; + press_enter_prompt(&mut stdout)?; } - stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?; - press_enter_prompt(&mut stdout)?; - create_dir(rustlings_dir).context("Failed to create the `rustlings/` directory")?; set_current_dir(rustlings_dir) .context("Failed to change the current directory to `rustlings/`")?;