From 0e03745f0bd27305e523ffe871c7ce16b2b0e0b6 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Tue, 8 Dec 2020 16:18:38 -0600 Subject: [PATCH] feat: add -C / --create-config directory --- src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main.rs b/src/main.rs index 8149248..46b6764 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,18 @@ use std::fs; use std::path::PathBuf; 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(); 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 { let alert_dir = ProjectDirs::from("moe", "paoda", "domasi") .unwrap()