To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 2f4820b4 authored by Stefan Schindler's avatar Stefan Schindler
Browse files

Display all information when listing the disks

parent 625d6123
......@@ -30,18 +30,17 @@ fn main() {
let disks = parse_disks();
let pool = threadpool::ThreadPool::new(2);
list_disks(&disks);
show_disk_status(&disks);
loop {
println!("\nPress {} to exit, {} for a list of available commands", BOLD.paint("q"), BOLD.paint("h"));
let input = read_one_line_from_stdin();
match input.trim() {
"q" => return,
"l" => list_disks(&disks),
"h" => print_help(),
"l" => show_disk_status(&disks),
"w" => select_disk_to_whipe(&disks),
"" => {},
"" => show_disk_status(&disks),
com => println!("unknown command: {}", com),
}
......@@ -49,11 +48,21 @@ fn main() {
}
}
fn list_disks(disks: &Vec<Arc<DiskInformation>>) {
println!("{}", HEADING.paint("Found following disks:") );
fn show_disk_status(disks: &Vec<Arc<DiskInformation>>) {
println!("{}", HEADING.paint("Status of found disks:") );
let longest = disks.iter().fold(0, |b, e| std::cmp::max(b, e.name.len())) +1;
for disk in disks {
println!(" {}) {}: {}", disk.id, BOLD.paint(&*disk.name), disk.size);
println!("{:6}) {}:{:width$} {} -- {:?}",
disk.id,
BOLD.paint(&*disk.name),
" ",
disk.size,
*disk.state.lock().unwrap(),
width = longest - disk.name.len()
);
}
}
......@@ -249,13 +258,12 @@ fn print_help() {
let options = [
("q", "quit"),
("h", "print this help"),
("l", "list found disks"),
("l", "list found disks and status"),
("w", "start whiping a disk"),
("s", "show status updates"),
];
for option in options.iter() {
println!(" {} {}", BOLD.paint(option.0), option.1);
println!(" {} {}", BOLD.paint(option.0), option.1);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment