Skip to content

Commit

Permalink
refactor: add MySQL user and password options to command line flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Kremilly committed Oct 24, 2024
1 parent 5056f9b commit 23e8eba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/args_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ 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>,
}
20 changes: 13 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ 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(
&Env::get_var("DB_USER"),
&Env::get_var("DB_PASSWORD"),
&dbname,
&backup_path,
interval
).make_dump();
Dump::new(&user, &password, &dbname, &backup_path, interval).make_dump();
}

0 comments on commit 23e8eba

Please sign in to comment.