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