From 5a55636c657659212cd5b6a059a240a362d8c3ba Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 28 Dec 2015 13:28:25 +0100 Subject: [PATCH] Implement: BM: command_list() --- src/module/bm/mod.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index f463cf37..07c6e907 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -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> {