diff options
author | Daniel <kingdread@gmx.de> | 2020-05-12 13:51:09 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-05-12 13:51:09 +0200 |
commit | 371186e872df3518bb5a2894f487ec02a42c771a (patch) | |
tree | 1f49b34df2f9d44708076928d3868534064f634a | |
parent | f2f2582d546327be9e0254dea8370a9bb6b749f7 (diff) | |
download | raidgrep-371186e872df3518bb5a2894f487ec02a42c771a.tar.gz raidgrep-371186e872df3518bb5a2894f487ec02a42c771a.tar.bz2 raidgrep-371186e872df3518bb5a2894f487ec02a42c771a.zip |
add a -cm filter
-rw-r--r-- | raidgrep.1.asciidoc | 3 | ||||
-rw-r--r-- | src/fexpr/grammar.lalrpop | 1 | ||||
-rw-r--r-- | src/filters/log.rs | 14 | ||||
-rw-r--r-- | src/main.rs | 1 |
4 files changed, 19 insertions, 0 deletions
diff --git a/raidgrep.1.asciidoc b/raidgrep.1.asciidoc index 1cbdf85..30e0b2f 100644 --- a/raidgrep.1.asciidoc +++ b/raidgrep.1.asciidoc @@ -108,6 +108,9 @@ Those predicates can be used as-is in the filter: Include logs from the given bosses. See below for a list of valid boss names. Names can also be comma separated. +*-cm*:: + Include logs that were done with the Challenge Mote enabled. + *-player* 'REGEX':: Include logs in which at least one player's account or character name matches the given regex. + diff --git a/src/fexpr/grammar.lalrpop b/src/fexpr/grammar.lalrpop index f91da19..1540aae 100644 --- a/src/fexpr/grammar.lalrpop +++ b/src/fexpr/grammar.lalrpop @@ -55,6 +55,7 @@ LogPredicate: Box<dyn filters::log::LogFilter> = { "-log-after" <Date> => filters::log::log_after(<>), "-boss" <Comma<Boss>> => filters::log::boss(<>), + "-cm" => filters::log::challenge_mote(), "-include" => filters::constant(true), "-exclude" => filters::constant(false), diff --git a/src/filters/log.rs b/src/filters/log.rs index b9843e9..79513d5 100644 --- a/src/filters/log.rs +++ b/src/filters/log.rs @@ -186,6 +186,20 @@ pub fn log_before(when: DateTime<Utc>) -> Box<dyn LogFilter> { log_time(None, Some(when)) } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +struct CmFilter; + +impl Filter<EarlyLogResult, LogResult> for CmFilter { + fn filter(&self, log: &LogResult) -> bool { + log.is_cm + } +} + +/// A filter that only includes logs that had the Challenge Mote turned on. +pub fn challenge_mote() -> Box<dyn LogFilter> { + Box::new(CmFilter) +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/main.rs b/src/main.rs index 74fcf7f..e8ed255 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,7 @@ const APP_NAME: &str = "raidgrep"; /// -before DATE Only include logs from before the given date. /// -after DATE Only include logs from after the given date. /// -boss BOSSES Only include logs from the given bosses. +/// -cm Only include logs with challenge mote enabled. /// -player REGEX Shorthand to check if any player in the log has the given name. /// -include Always evaluates to including the log. /// -exclude Always evaluates to excluding the log. |