You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
1.4 KiB
92 lines
1.4 KiB
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<OutputType>,
|
|
pub tags: Vec<tags::Tag>,
|
|
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<Self, Self::Err>
|
|
{
|
|
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())),
|
|
})
|
|
}
|
|
}
|