diff --git a/src/helpers.rs b/src/helpers.rs index b79fdb0..8ed697c 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -11,9 +11,20 @@ pub fn prompt_microstructure_variable(connection: &mut PgConnection) -> Option Option { let mut input = String::new(); // Read user input - io::stdin() - .read_line(&mut input) - .expect("Failed to read input"); + loop { + input.clear(); + let bytes = io::stdin() + .read_line(&mut input) + .expect("Failed to read input"); + + if bytes == 0 { + return None; // EOF + } + + if !input.trim().is_empty() { + break; + } + } // The user can only enter a number for now, anything else will exit the function. if let Ok(divide) = input.trim().parse::() {