Add builtin module with PlainViewer
This commit is contained in:
parent
3ab8c9038c
commit
c956472616
3 changed files with 32 additions and 0 deletions
1
libimagentryview/src/builtin/mod.rs
Normal file
1
libimagentryview/src/builtin/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod plain;
|
30
libimagentryview/src/builtin/plain.rs
Normal file
30
libimagentryview/src/builtin/plain.rs
Normal 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(())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue