diff options
author | Daniel <kingdread@gmx.de> | 2020-05-14 16:13:28 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-05-14 16:13:28 +0200 |
commit | c973f2ddb47721254f6f5a81e4c45f0c72d793fd (patch) | |
tree | 4aa7c00b87eec09ee1faca957be508efe3dbbb65 /src/output/mod.rs | |
parent | 331d6b1762d1d9431b210fc98a495d56ad7a1cd1 (diff) | |
parent | e2d23d4b76000263e9f939637353bbc4bb9289fd (diff) | |
download | raidgrep-c973f2ddb47721254f6f5a81e4c45f0c72d793fd.tar.gz raidgrep-c973f2ddb47721254f6f5a81e4c45f0c72d793fd.tar.bz2 raidgrep-c973f2ddb47721254f6f5a81e4c45f0c72d793fd.zip |
Merge branch 'sorted-output'
Diffstat (limited to 'src/output/mod.rs')
-rw-r--r-- | src/output/mod.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/output/mod.rs b/src/output/mod.rs index 0fd92d9..c1cd787 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::{aggregators::Aggregator, formats::Format}; /// 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) } |