From dfbf78622b0869f070d062b3edd40c4a97ce7dfd Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 16 Feb 2019 01:48:59 +0100 Subject: introduce CommaSeparatedList This gives a common interface for command line flags which take multiple values, possibly with negation. This might come in useful if we add filtering by boss, e.g. "--boss !deimos" to ignore all deimos logs. --- src/filters.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/filters.rs') diff --git a/src/filters.rs b/src/filters.rs index 6980900..f9db377 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -1,6 +1,6 @@ use evtclib::{AgentName, Log}; -use super::{LogResult, Opt}; +use super::{SearchField, FightOutcome, LogResult, Opt}; /// Do filtering based on the character or account name. pub fn filter_name(log: &Log, opt: &Opt) -> bool { @@ -11,8 +11,8 @@ pub fn filter_name(log: &Log, opt: &Opt) -> bool { character_name, .. } => { - if (opt.field.search_account() && opt.expression.is_match(account_name)) - || (opt.field.search_character() && opt.expression.is_match(character_name)) + if (opt.field.contains(&SearchField::Account) && opt.expression.is_match(account_name)) + || (opt.field.contains(&SearchField::Character) && opt.expression.is_match(character_name)) { return true; } @@ -25,11 +25,7 @@ pub fn filter_name(log: &Log, opt: &Opt) -> bool { /// Do filtering based on the fight outcome. pub fn filter_outcome(result: &LogResult, opt: &Opt) -> bool { - match opt.outcome { - Some(o) if o == result.outcome => true, - None => true, - _ => false, - } + opt.outcome.contains(&result.outcome) } /// Do filtering based on encounter time. -- cgit v1.2.3