Skip to content

Commit 82ebd29

Browse files
committed
Add a special confirmation for initialization in a workspace
1 parent f5737b5 commit 82ebd29

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/init.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ pub fn init() -> Result<()> {
5757
bail!("The current directory is already part of a Cargo project.\nPlease initialize Rustlings in a different directory");
5858
}
5959

60+
stdout.write_all(b"This command will create the directory `rustlings/` as a member of this Cargo workspace.\nPress ENTER to continue ")?;
61+
press_enter_prompt(&mut stdout)?;
62+
6063
// Make sure "rustlings" is added to `workspace.members` by making
6164
// Cargo initialize a new project.
6265
let status = Command::new("cargo")
@@ -76,11 +79,11 @@ pub fn init() -> Result<()> {
7679
fs::remove_dir_all("rustlings")
7780
.context("Failed to remove the temporary directory `rustlings/`")?;
7881
init_git = false;
82+
} else {
83+
stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?;
84+
press_enter_prompt(&mut stdout)?;
7985
}
8086

81-
stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?;
82-
press_enter_prompt(&mut stdout)?;
83-
8487
create_dir(rustlings_dir).context("Failed to create the `rustlings/` directory")?;
8588
set_current_dir(rustlings_dir)
8689
.context("Failed to change the current directory to `rustlings/`")?;

0 commit comments

Comments
 (0)