diff options
author | Daniel <kingdread@gmx.de> | 2020-05-13 13:49:43 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-05-13 13:49:43 +0200 |
commit | fb2a6088dcc7b57a2c1ac93ec6a8fbcc52584734 (patch) | |
tree | 66979361f60dad90f6c9b0eff7c5bf20404357e8 /src/main.rs | |
parent | 331d6b1762d1d9431b210fc98a495d56ad7a1cd1 (diff) | |
download | raidgrep-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/main.rs')
-rw-r--r-- | src/main.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index ee1c232..ad996ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,7 @@ use filters::{log::LogFilter, Inclusion}; mod guilds; mod logger; mod output; +use output::sorting::Sorting; mod paths; mod playerclass; use playerclass::PlayerClass; @@ -79,6 +80,10 @@ pub struct Opt { #[structopt(long = "no-color")] no_color: bool, + /// Sort the output. + #[structopt(short = "s", long = "sort")] + sorting: Option<Sorting>, + /// Print more debugging information to stderr. #[structopt(long = "debug")] debug: bool, @@ -150,7 +155,7 @@ impl Ord for Player { } /// Outcome of the fight. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum FightOutcome { Success, Wipe, @@ -377,7 +382,8 @@ fn build_filter(expr_string: &str) -> Result<Box<dyn LogFilter>> { /// Run the grep search with the given options. fn grep(opt: &Opt, filter: &dyn LogFilter) -> Result<()> { - let pipeline = &output::build_pipeline(opt); + let pipeline = output::build_pipeline(opt); + let pipeline_ref = &pipeline; rayon::scope(|s| { let walker = WalkDir::new(&opt.path); for entry in walker { @@ -391,7 +397,7 @@ fn grep(opt: &Opt, filter: &dyn LogFilter) -> Result<()> { let search = search_log(&entry, filter); match search { Ok(None) => (), - Ok(Some(result)) => pipeline.push_item(&result), + Ok(Some(result)) => pipeline_ref.push_item(result), Err(err) => { debug!("Runtime error while scanning {:?}: {}", entry.path(), err); } @@ -400,7 +406,9 @@ fn grep(opt: &Opt, filter: &dyn LogFilter) -> Result<()> { }); } Ok(()) - }) + }) as Result<()>; + pipeline.finish(); + Ok(()) } /// Search the given single log. |