|
|
|
@ -1,6 +1,26 @@
|
|
|
|
use clap::Parser;
|
|
|
|
use clap::Parser;
|
|
|
|
use r2d2::Pool;
|
|
|
|
use r2d2::Pool;
|
|
|
|
use r2d2_sqlite::SqliteConnectionManager;
|
|
|
|
use r2d2_sqlite::SqliteConnectionManager;
|
|
|
|
|
|
|
|
use regex::Regex;
|
|
|
|
|
|
|
|
use unidecode::unidecode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub trait NormalizeName {
|
|
|
|
|
|
|
|
fn normalize_name(&self) -> String;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl NormalizeName for String {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn normalize_name(&self) -> String {
|
|
|
|
|
|
|
|
let space_re = Regex::new(r"[\s_]+").unwrap();
|
|
|
|
|
|
|
|
let remove_re = Regex::new(r"[^a-z0-9_]").unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut str = unidecode(self);
|
|
|
|
|
|
|
|
str = space_re.replace_all(&str, "_").to_string();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
remove_re.replace_all(&str, "").to_string().to_lowercase()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Parser)]
|
|
|
|
#[derive(Parser)]
|
|
|
|
pub struct Arguments {
|
|
|
|
pub struct Arguments {
|
|
|
|
@ -19,12 +39,10 @@ pub struct Arguments {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Arguments {
|
|
|
|
impl Arguments {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn parse_args() -> Arguments {
|
|
|
|
pub fn parse_args() -> Arguments {
|
|
|
|
let args = Arguments::parse();
|
|
|
|
let args = Arguments::parse();
|
|
|
|
args
|
|
|
|
args
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
#[derive(Clone)]
|
|
|
|
|