summaryrefslogtreecommitdiffstats
path: root/libimagentryview
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-04-18 19:59:05 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-04-18 19:59:05 +0200
commitc95647261603007bd43d2f14554af34bb035acf5 (patch)
treea51a32ff1ec065f084e81c6e5cf024b325382308 /libimagentryview
parent3ab8c9038c7df0337ebf18d8609a042ebba09c58 (diff)
Add builtin module with PlainViewer
Diffstat (limited to 'libimagentryview')
-rw-r--r--libimagentryview/src/builtin/mod.rs1
-rw-r--r--libimagentryview/src/builtin/plain.rs30
-rw-r--r--libimagentryview/src/lib.rs1
3 files changed, 32 insertions, 0 deletions
diff --git a/libimagentryview/src/builtin/mod.rs b/libimagentryview/src/builtin/mod.rs
new file mode 100644
index 00000000..6c83de88
--- /dev/null
+++ b/libimagentryview/src/builtin/mod.rs
@@ -0,0 +1 @@
+pub mod plain;
diff --git a/libimagentryview/src/builtin/plain.rs b/libimagentryview/src/builtin/plain.rs
new file mode 100644
index 00000000..02ff5fc8
--- /dev/null
+++ b/libimagentryview/src/builtin/plain.rs
@@ -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(())
+ }
+
+}
diff --git a/libimagentryview/src/lib.rs b/libimagentryview/src/lib.rs
index 35d15053..73833b7d 100644
--- a/libimagentryview/src/lib.rs
+++ b/libimagentryview/src/lib.rs
@@ -17,6 +17,7 @@
extern crate libimagstore;
pub mod error;
+pub mod builtin;
pub mod result;
pub mod viewer;