From c99ef1a7b069bdc8126c9e31b2cb833f61de6cec Mon Sep 17 00:00:00 2001 From: Valerie Date: Wed, 23 Jun 2021 10:59:44 -0400 Subject: [PATCH] added -h/--help and -a/--add flags. --- src/config.rs | 12 ++++++------ src/main.rs | 7 ++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index d4505f6..b004fb5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -58,13 +58,13 @@ impl Config { // prepare path vars let global_path: Option; if global.is_some() { - global_path = Some(i_dir_global.to_string()); + global_path = Some(path_global.to_str().unwrap().to_string()); } else { global_path = None } let local_path: Option; if local.is_some() { - local_path = Some(dir_local.to_str().unwrap().to_string()); + local_path = Some(dir_local.join(".open").to_str().unwrap().to_string()); } else { local_path = None; } @@ -116,13 +116,13 @@ impl Config { global.set(section, key, Some(value)); self.global = Some(global); } - pub fn write(&self) { + pub fn write(&self) -> std::io::Result<()> { let mut path = self.local_path.as_ref(); if path.is_some() { - self.local.as_ref().unwrap().write(path.unwrap().as_str()).ok(); - return; + let result = self.local.as_ref().unwrap().write(path.unwrap().as_str()); + return result; } path = self.global_path.as_ref(); - self.global.as_ref().unwrap().write(path.unwrap().as_str()).ok(); + self.global.as_ref().unwrap().write(path.unwrap().as_str()) } } diff --git a/src/main.rs b/src/main.rs index b1e9cc3..c31d7f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,11 +45,12 @@ FLAGS: let exe = args.get(3).unwrap(); let tmp = args.get(4); let shell = tmp.is_some() && tmp.unwrap() == "shell"; + println!("{} {} {}", ext, exe, shell); config.add(ext, "command", exe.to_string()); if shell { config.add(ext, "shell", "true".to_string()); } - config.write(); + config.write().ok(); return; } _ => { @@ -122,7 +123,3 @@ FLAGS: command.spawn().ok(); } } - -fn get_ext() { - -}