diff options
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) } |