Skip to content

Commit

Permalink
refactor: add backup path option 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 d5cc116 commit 58bf9af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/args_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ pub struct Flags {
#[arg(short, long)]
/// Database name
pub database: Option<String>,

#[arg(short, long)]
/// Backup path
pub folder: Option<String>,
}
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,26 @@ fn main() {
let dbname = if Flags::parse().database != None {
Flags::parse().database.unwrap()
} else {
Env::get_var("DUMP_INTERVAL")
Env::get_var("DB_NAME")
};

let interval = if Flags::parse().interval != None {
Flags::parse().interval.unwrap()
} else {
Env::get_var_u64("DUMP_INTERVAL")
};

let backup_path = if Flags::parse().folder != None {
Flags::parse().folder.unwrap()
} else {
Env::get_var("BACKUP_PATH")
};

Dump::new(
&Env::get_var("DB_USER"),
&Env::get_var("DB_PASSWORD"),
&dbname,
&Env::get_var("BACKUP_PATH"),
&backup_path,
interval
).make_dump();
}

0 comments on commit 58bf9af

Please sign in to comment.