use super::*; use std::{ path::PathBuf, str, }; #[derive(Debug, PartialEq, Eq, Hash)] pub enum Rating { Safe, Questionable, Explicit, } impl Rating { pub fn as_str(&self) -> &str { match self { Rating::Safe => "s", Rating::Questionable => "q", Rating::Explicit => "e", } } } #[derive(Debug, PartialEq, Eq, Hash)] pub enum Verbosity { Full, Silent, } impl Default for Verbosity { fn default() -> Self { Self::Full } } #[derive(Debug, PartialEq, Eq, Hash)] pub enum OutputType { File(PathBuf), Directory(PathBuf), } #[derive(Debug, PartialEq, Eq, Hash)] pub struct Config { pub rating: Rating, pub output: Vec, pub tags: Vec, pub verbose: Verbosity, } impl Default for Rating { fn default() -> Self { Self::Safe } } impl Default for Config { fn default() -> Self { Self { rating: Rating::default(), output: Vec::new(), tags: Vec::new(), verbose: Default::default(), } } } impl str::FromStr for Rating { type Err = args::Error; fn from_str(s: &str) -> Result { Ok(match s.chars().next() { Some('e') | Some('E') => Self::Explicit, Some('q') | Some('Q') => Self::Questionable, Some('s') | Some('S') => Self::Safe, _ => return Err(args::Error::UnknownRating(s.to_owned())), }) } }