feat: add -C / --create-config directory

This commit is contained in:
Rekai Nyangadzayi Musuka 2020-12-08 16:18:38 -06:00
parent 0346154f7b
commit 0e03745f0b
1 changed files with 23 additions and 0 deletions

View File

@ -5,6 +5,18 @@ use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
fn main() { fn main() {
let mut args = std::env::args_os();
if let Some(os_string) = args.nth(1) {
match os_string.to_str() {
Some("-C") | Some("--create-config") => {
let _ = create_alert_directory();
}
None => {}
arg => println!("Unsupported Argument: {}", arg.unwrap()),
}
}
let mut domasi: Pomodoro = Default::default(); let mut domasi: Pomodoro = Default::default();
match get_alert() { match get_alert() {
@ -13,6 +25,17 @@ fn main() {
} }
} }
fn create_alert_directory() -> std::io::Result<()> {
let alert_dir = ProjectDirs::from("moe", "paoda", "domasi")
.unwrap()
.data_dir()
.to_path_buf()
.join("alert");
fs::create_dir_all(alert_dir)?;
Ok(())
}
fn get_alert() -> Option<Alert> { fn get_alert() -> Option<Alert> {
let alert_dir = ProjectDirs::from("moe", "paoda", "domasi") let alert_dir = ProjectDirs::from("moe", "paoda", "domasi")
.unwrap() .unwrap()