aboutsummaryrefslogtreecommitdiff
path: root/src/output/mod.rs
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2019-06-03 02:02:44 +0200
committerDaniel <kingdread@gmx.de>2019-06-03 02:02:44 +0200
commit5d2f51ab8593946a0f24db367a887a37258901d5 (patch)
tree498f2af9584046ed63f256375169bbf5756bfb7d /src/output/mod.rs
parentc731b470fc162e56f6d81c475bacb41230a5e2d3 (diff)
downloadraidgrep-5d2f51ab8593946a0f24db367a887a37258901d5.tar.gz
raidgrep-5d2f51ab8593946a0f24db367a887a37258901d5.tar.bz2
raidgrep-5d2f51ab8593946a0f24db367a887a37258901d5.zip
[WIP] rewrite output logic as a pipeline
Diffstat (limited to 'src/output/mod.rs')
-rw-r--r--src/output/mod.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/output/mod.rs b/src/output/mod.rs
new file mode 100644
index 0000000..dfb3ea8
--- /dev/null
+++ b/src/output/mod.rs
@@ -0,0 +1,26 @@
+use super::errors::RuntimeError;
+use super::{FightOutcome, LogResult, Opt};
+
+use std::io;
+
+pub mod formats;
+pub mod aggregators;
+pub mod pipeline;
+
+use self::formats::Format;
+use self::aggregators::Aggregator;
+pub use self::pipeline::Pipeline;
+
+
+/// Build an pipeline for the given command line options.
+pub fn build_pipeline(opt: &Opt) -> Pipeline {
+ let stream = io::stdout();
+
+ let formatter: Box<dyn Format> = if opt.file_name_only {
+ Box::new(formats::FileOnly)
+ } else {
+ Box::new(formats::HumanReadable)
+ };
+
+ Pipeline::new(stream, formatter, aggregators::WriteThrough)
+}