aboutsummaryrefslogtreecommitdiff
path: root/src/output/mod.rs
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-05-13 13:49:43 +0200
committerDaniel <kingdread@gmx.de>2020-05-13 13:49:43 +0200
commitfb2a6088dcc7b57a2c1ac93ec6a8fbcc52584734 (patch)
tree66979361f60dad90f6c9b0eff7c5bf20404357e8 /src/output/mod.rs
parent331d6b1762d1d9431b210fc98a495d56ad7a1cd1 (diff)
downloadraidgrep-fb2a6088dcc7b57a2c1ac93ec6a8fbcc52584734.tar.gz
raidgrep-fb2a6088dcc7b57a2c1ac93ec6a8fbcc52584734.tar.bz2
raidgrep-fb2a6088dcc7b57a2c1ac93ec6a8fbcc52584734.zip
first attempt at sorting output
This does currently not work yet, as we cannot call .finish() on dyn Aggregator. This needs to be adjusted. However, this provides the basic infrastructure for producing sorted output, including the required command line parsing.
Diffstat (limited to 'src/output/mod.rs')
-rw-r--r--src/output/mod.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/output/mod.rs b/src/output/mod.rs
index 0fd92d9..18ab84b 100644
--- a/src/output/mod.rs
+++ b/src/output/mod.rs
@@ -5,15 +5,20 @@ use std::io;
pub mod aggregators;
pub mod formats;
pub mod pipeline;
+pub mod sorting;
pub use self::pipeline::Pipeline;
-use self::formats::Format;
+use self::{formats::Format, aggregators::Aggregator};
/// Build an pipeline for the given command line options.
pub fn build_pipeline(opt: &Opt) -> Pipeline {
let stream = io::stdout();
- let aggregator = aggregators::WriteThrough;
+ let aggregator: Box<dyn Aggregator> = if let Some(sorting) = &opt.sorting {
+ Box::new(aggregators::SortedOutput::new(sorting.clone()))
+ } else {
+ Box::new(aggregators::WriteThrough)
+ };
let format: Box<dyn Format> = if opt.file_name_only {
Box::new(formats::FileOnly)
@@ -23,5 +28,5 @@ pub fn build_pipeline(opt: &Opt) -> Pipeline {
})
};
- Pipeline::new(Box::new(stream), format, Box::new(aggregator))
+ Pipeline::new(Box::new(stream), format, aggregator)
}