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() { ...@@ -30,18 +30,17 @@ fn main() {
let disks = parse_disks(); let disks = parse_disks();
let pool = threadpool::ThreadPool::new(2); let pool = threadpool::ThreadPool::new(2);
list_disks(&disks); show_disk_status(&disks);
loop { loop {
println!("\nPress {} to exit, {} for a list of available commands", BOLD.paint("q"), BOLD.paint("h")); println!("\nPress {} to exit, {} for a list of available commands", BOLD.paint("q"), BOLD.paint("h"));
let input = read_one_line_from_stdin(); let input = read_one_line_from_stdin();
match input.trim() { match input.trim() {
"q" => return, "q" => return,
"l" => list_disks(&disks),
"h" => print_help(), "h" => print_help(),
"l" => show_disk_status(&disks),
"w" => select_disk_to_whipe(&disks), "w" => select_disk_to_whipe(&disks),
"" => {}, "" => show_disk_status(&disks),
com => println!("unknown command: {}", com), com => println!("unknown command: {}", com),
} }
...@@ -49,11 +48,21 @@ fn main() { ...@@ -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 { 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() { ...@@ -249,13 +258,12 @@ fn print_help() {
let options = [ let options = [
("q", "quit"), ("q", "quit"),
("h", "print this help"), ("h", "print this help"),
("l", "list found disks"), ("l", "list found disks and status"),
("w", "start whiping a disk"), ("w", "start whiping a disk"),
("s", "show status updates"),
]; ];
for option in options.iter() { for option in options.iter() {
println!(" {} {}", BOLD.paint(option.0), option.1); println!(" {} {}", BOLD.paint(option.0), option.1);
} }
} }
......
Supports Markdown
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