diff --git a/src/ui/file.rs b/src/ui/file.rs index e9ab2e38..a45bb71e 100644 --- a/src/ui/file.rs +++ b/src/ui/file.rs @@ -158,4 +158,41 @@ impl FilePrinter for TablePrinter { } } + fn print_files_custom(&self, files: I, f: &F) + where I: Iterator>>, + F: Fn(Rc>) -> String + { + use prettytable::Table; + use prettytable::row::Row; + use prettytable::cell::Cell; + + let titles = row!["File#", "Owner", "ID", "..."]; + + let mut tab = Table::new(); + tab.set_titles(titles); + + let mut i = 0; + for file in files { + debug!("Printing file: {:?}", file); + i += 1; + let cell_i = Cell::new(&format!("{}", i)[..]); + let cell_o = Cell::new(&format!("{}", file.deref().borrow().owner_name())[..]); + + let id : String = file.deref().borrow().id().clone().into(); + let cell_id = Cell::new(&id[..]); + + let cell_extra = Cell::new(&f(file)[..]); + + let row = Row::new(vec![cell_i, cell_o, cell_id, cell_extra]); + tab.add_row(row); + } + + if i != 0 { + debug!("Printing {} table entries", i); + tab.printstd(); + } else { + debug!("Not printing table because there are zero entries"); + } + } + }