Move ::new() out of FilePrinter trait
This commit is contained in:
parent
aaf3660f31
commit
71f37f69c3
2 changed files with 19 additions and 10 deletions
|
@ -299,7 +299,6 @@ impl<'a> Notes<'a> {
|
|||
fn command_links(&self, matches: &ArgMatches) -> bool {
|
||||
use ansi_term::Colour::{Red, Green};
|
||||
use module::helpers::content::markdown::MarkdownParser;
|
||||
use ui::file::FilePrinter;
|
||||
use util::is_url;
|
||||
use prettytable::Table;
|
||||
use prettytable::row::Row;
|
||||
|
|
|
@ -10,8 +10,6 @@ use storage::file::File;
|
|||
*/
|
||||
pub trait FilePrinter {
|
||||
|
||||
fn new(verbose: bool, debug: bool) -> Self;
|
||||
|
||||
/*
|
||||
* Print a single file
|
||||
*/
|
||||
|
@ -50,14 +48,18 @@ struct DebugPrinter {
|
|||
debug: bool,
|
||||
}
|
||||
|
||||
impl FilePrinter for DebugPrinter {
|
||||
impl DebugPrinter {
|
||||
|
||||
fn new(_: bool, debug: bool) -> DebugPrinter {
|
||||
pub fn new(debug: bool) -> DebugPrinter {
|
||||
DebugPrinter {
|
||||
debug: debug,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl FilePrinter for DebugPrinter {
|
||||
|
||||
fn print_file(&self, f: Rc<RefCell<File>>) {
|
||||
if self.debug {
|
||||
debug!("[DebugPrinter] ->\n{:?}", f);
|
||||
|
@ -82,15 +84,19 @@ struct SimplePrinter {
|
|||
debug: bool,
|
||||
}
|
||||
|
||||
impl FilePrinter for SimplePrinter {
|
||||
impl SimplePrinter {
|
||||
|
||||
fn new(verbose: bool, debug: bool) -> SimplePrinter {
|
||||
pub fn new(verbose: bool, debug: bool) -> SimplePrinter {
|
||||
SimplePrinter {
|
||||
debug: debug,
|
||||
verbose: verbose,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl FilePrinter for SimplePrinter {
|
||||
|
||||
fn print_file(&self, f: Rc<RefCell<File>>) {
|
||||
use ansi_term::Colour::Cyan;
|
||||
|
||||
|
@ -127,14 +133,18 @@ pub struct TablePrinter {
|
|||
sp: SimplePrinter,
|
||||
}
|
||||
|
||||
impl FilePrinter for TablePrinter {
|
||||
impl TablePrinter {
|
||||
|
||||
fn new(verbose: bool, debug: bool) -> TablePrinter {
|
||||
pub fn new(verbose: bool, debug: bool) -> TablePrinter {
|
||||
TablePrinter {
|
||||
sp: SimplePrinter::new(verbose, debug),
|
||||
sp: SimplePrinter::new(verbose, debug),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl FilePrinter for TablePrinter {
|
||||
|
||||
fn print_file(&self, f: Rc<RefCell<File>>) {
|
||||
self.sp.print_file(f);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue