diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/main.rs b/src/main.rs index a77a952..13d0a76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,9 @@ mod output; mod filters; +mod csl; +use csl::CommaSeparatedList; + macro_rules! unwrap { ($p:pat = $e:expr => { $r:expr} ) => { if let $p = $e { @@ -75,12 +78,12 @@ pub struct Opt { path: PathBuf, /// The fields which should be searched. - #[structopt(short = "f", long = "fields", default_value = "all")] - field: SearchField, + #[structopt(short = "f", long = "fields", default_value = "*")] + field: CommaSeparatedList<SearchField>, /// Only display fights with the given outcome. - #[structopt(short = "o", long = "outcome")] - outcome: Option<FightOutcome>, + #[structopt(short = "o", long = "outcome", default_value = "*")] + outcome: CommaSeparatedList<FightOutcome>, /// Disable colored output. #[structopt(long = "no-color")] @@ -112,39 +115,22 @@ pub struct Opt { } /// A flag indicating which fields should be searched. -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] enum SearchField { - /// Search all fields. - All, /// Only search the account name. Account, /// Only search the character name. Character, } -impl SearchField { - /// True if the state says that the account name should be searched. - #[inline] - fn search_account(self) -> bool { - self == SearchField::All || self == SearchField::Account - } - - /// True if the state says that the character name should be searched. - #[inline] - fn search_character(self) -> bool { - self == SearchField::All || self == SearchField::Character - } -} - impl FromStr for SearchField { type Err = &'static str; fn from_str(s: &str) -> Result<Self, Self::Err> { match s { - "all" => Ok(SearchField::All), "account" => Ok(SearchField::Account), "character" => Ok(SearchField::Character), - _ => Err("Must be all, account or character"), + _ => Err("Must be account or character"), } } } @@ -178,7 +164,7 @@ pub struct Player { } /// Outcome of the fight. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FightOutcome { Success, Wipe, |