Ignore bad retry answer (fix #86)

This commit is contained in:
Roey Darwish Dror
2018-11-10 20:18:43 +02:00
parent 663eb027c5
commit c333f9d813

View File

@@ -63,28 +63,29 @@ impl Terminal {
} }
println!(); println!();
loop { self.term
self.term .write_fmt(format_args!(
.write_fmt(format_args!( "{}",
"{}", style(format!(
style(format!( "Retry? [y/N] {}",
"Retry? [y/N] {}", if !running {
if !running { "(Press Ctrl+C again to stop Topgrade) "
"(Press Ctrl+C again to stop Topgrade) " } else {
} else { ""
"" }
} )).yellow()
)).yellow() .bold()
.bold() )).ok();
)).ok();
let answer = self.term.read_char()?; let answer = loop {
println!(); match self.term.read_char()? {
match answer { 'y' | 'Y' => break Ok(true),
'y' | 'Y' => return Ok(true), 'n' | 'N' | '\r' | '\n' => break Ok(false),
'n' | 'N' | '\r' | '\n' => return Ok(false),
_ => (), _ => (),
} }
} };
println!();
answer
} }
} }