Skip to content

Commit

Permalink
refactor: remove unused command line flags for MySQL user and password
Browse files Browse the repository at this point in the history
  • Loading branch information
Kremilly committed Oct 24, 2024
1 parent 23e8eba commit 4871f36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
8 changes: 0 additions & 8 deletions src/args_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,4 @@ pub struct Flags {
#[arg(short, long)]
/// Backup path
pub folder: Option<String>,

#[arg(short, long)]
/// Set MySQL password
pub password: Option<String>,

#[arg(short, long)]
/// Set MySQL user
pub user: Option<String>,
}
4 changes: 4 additions & 0 deletions src/engine/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

}
20 changes: 7 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 4871f36

Please sign in to comment.