Implement: BM: command_list()

This commit is contained in:
Matthias Beyer 2015-12-28 13:28:25 +01:00
parent bd9abf3bc7
commit 5a55636c65

View file

@ -51,14 +51,35 @@ impl<'a> BM<'a> {
}
fn command_list(&self, matches: &ArgMatches) -> bool {
unimplemented!()
use ui::file::{FilePrinter, TablePrinter};
use self::header::get_url_from_header;
use self::header::get_tags_from_header;
use std::ops::Deref;
let parser = Parser::new(JsonHeaderParser::new(None));
let files = self.rt.store().load_for_module(self, &parser);
let printer = TablePrinter::new(self.rt.is_verbose(), self.rt.is_debugging());
printer.print_files_custom(files.into_iter(),
&|file| {
let fl = file.deref().borrow();
let hdr = fl.header();
let url = get_url_from_header(hdr).unwrap_or(String::from("Parser error"));
let tags = get_tags_from_header(hdr);
debug!("Custom printer field: url = '{:?}'", url);
debug!("Custom printer field: tags = '{:?}'", tags);
vec![url, tags.join(", ")]
}
);
true
}
fn command_remove(&self, matches: &ArgMatches) -> bool {
unimplemented!()
}
}
impl<'a> Module<'a> for BM<'a> {