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() { - -}