Add builtin module with PlainViewer

This commit is contained in:
Matthias Beyer 2016-04-18 19:59:05 +02:00
parent 3ab8c9038c
commit c956472616
3 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1 @@
pub mod plain;

View file

@ -0,0 +1,30 @@
use libimagstore::store::Entry;
use viewer::Viewer;
use result::Result;
pub struct PlainViewer {
show_header: bool
}
impl PlainViewer {
pub fn new(show_header: bool) -> PlainViewer {
PlainViewer {
show_header: show_header,
}
}
}
impl Viewer for PlainViewer {
fn view_entry(&self, e: &Entry) -> Result<()> {
if self.show_header {
println!("{}", e.get_header().header());
}
println!("{}", e.get_content());
Ok(())
}
}

View file

@ -17,6 +17,7 @@
extern crate libimagstore; extern crate libimagstore;
pub mod error; pub mod error;
pub mod builtin;
pub mod result; pub mod result;
pub mod viewer; pub mod viewer;