From c26bd4336d84f83d68c83c434b3fea6720af82e6 Mon Sep 17 00:00:00 2001 From: Marcelo Hernandez Date: Sun, 24 Dec 2023 03:36:02 -0500 Subject: [PATCH] revert delete question + remove deleted success message for brevity --- src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1d7ce7b..345b077 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,27 +56,25 @@ fn try_template(template: &str, editor: &str, delete: bool, data_dir: &Path) -> .wait() .expect("Could not launch editor!"); - if delete || ask_y_n("Would you like to delete this project?")? { - fs::remove_dir_all(&tmp_dir)?; - println!("Deleted.") - } else { + if delete || ask_y_n("Would you like to keep this project?")? { println!("Saved as {tmp_dir:?}."); + } else { + fs::remove_dir_all(&tmp_dir)?; } Ok(()) } fn ask_y_n(question: &str) -> anyhow::Result { - println!("{question} (Y/n)"); + println!("{question} (y/N)"); let mut input = String::new(); io::stdin().read_line(&mut input)?; match input.to_lowercase().trim() { - "" => Ok(true), // default to yes if only enter is pressed "y" => Ok(true), - "n" => Ok(false), - _ => ask_y_n(question), + "n" | "" => Ok(false), // default to no if no input + _ => ask_y_n(question), // redo if wrong input } }