diff --git a/src/args_cli.rs b/src/args_cli.rs index 16d226d..969c84b 100644 --- a/src/args_cli.rs +++ b/src/args_cli.rs @@ -14,12 +14,4 @@ pub struct Flags { #[arg(short, long)] /// Backup path pub folder: Option, - - #[arg(short, long)] - /// Set MySQL password - pub password: Option, - - #[arg(short, long)] - /// Set MySQL user - pub user: Option, } diff --git a/src/engine/env.rs b/src/engine/env.rs index 9e63c23..595dcb7 100644 --- a/src/engine/env.rs +++ b/src/engine/env.rs @@ -18,4 +18,8 @@ impl Env { env::var(var).expect(&format!("{} is not defined in the .env", var)).parse().expect(&format!("{} is not a valid number", var)) } + pub fn get_var_bool(var: &str) -> bool { + env::var(var).expect(&format!("{} is not defined in the .env", var)).parse().expect(&format!("{} is not a valid boolean", var)) + } + } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3a8875c..b77f7ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,18 +35,12 @@ fn main() { } else { Env::get_var("BACKUP_PATH") }; - - let user = if Flags::parse().user != None { - Flags::parse().user.unwrap() - } else { - Env::get_var("DB_USER") - }; - - let password = if Flags::parse().password != None { - Flags::parse().password.unwrap() - } else { - Env::get_var("DB_PASSWORD") - }; - Dump::new(&user, &password, &dbname, &backup_path, interval).make_dump(); + Dump::new( + &Env::get_var("DB_USER"), + &Env::get_var("DB_PASSWORD"), + &dbname, + &backup_path, + interval + ).make_dump(); }