manager cli: disk wipe: ask over stdout and drop now useless loop
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
887d83cb5e
commit
00b6152cde
@ -155,21 +155,17 @@ async fn wipe_disk(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<
|
||||
|
||||
// If we're on a TTY, query the user
|
||||
if std::io::stdin().is_terminal() {
|
||||
loop {
|
||||
eprintln!("You are about to wipe block device {}.", param["disk"]);
|
||||
eprint!("Are you sure you want to continue? (y/N): ");
|
||||
let _ = std::io::stdout().flush();
|
||||
use std::io::{BufRead, BufReader};
|
||||
let mut line = String::new();
|
||||
match BufReader::new(std::io::stdin()).read_line(&mut line) {
|
||||
Ok(_) => {
|
||||
match line.trim() {
|
||||
"y" | "Y" => break,
|
||||
_ => bail!("Aborting."),
|
||||
}
|
||||
}
|
||||
Err(err) => bail!("Failed to read line - {err}."),
|
||||
}
|
||||
println!("You are about to wipe block device {}.", param["disk"]);
|
||||
print!("Are you sure you want to continue? (y/N): ");
|
||||
let _ = std::io::stdout().flush();
|
||||
use std::io::{BufRead, BufReader};
|
||||
let mut line = String::new();
|
||||
match BufReader::new(std::io::stdin()).read_line(&mut line) {
|
||||
Ok(_) => match line.trim() {
|
||||
"y" | "Y" => (), // continue
|
||||
_ => bail!("Aborting."),
|
||||
},
|
||||
Err(err) => bail!("Failed to read line - {err}."),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user