diff --git a/Cargo.toml b/Cargo.toml index c23ad10..e2cd420 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "open" -version = "0.4.0" +version = "0.5.0" authors = ["Valerie Wolfe "] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -configparser = "2.0.1" +configparser = "3.0.0" diff --git a/src/config.rs b/src/config.rs index 1070ec6..6588dab 100644 --- a/src/config.rs +++ b/src/config.rs @@ -86,13 +86,15 @@ impl Config { } return output; } - pub fn getbool(&self, section: &str, key: &str) -> Result, String> { - let mut output = Ok(None); + pub fn getbool(&self, section: &str, key: &str) -> Option { + let mut output = None; if self.local.is_some() { - output = self.local.as_ref().unwrap().getbool(section, key); + let i_out = self.local.as_ref().unwrap().getbool(section, key); + output = i_out.unwrap_or(None); } - if output.clone().ok().is_none() && self.global.is_some() { - output = self.global.as_ref().unwrap().getbool(section, key); + if output.is_none() && self.global.is_some() { + let i_out = self.global.as_ref().unwrap().getbool(section, key); + output = i_out.unwrap_or(None); } return output; } @@ -105,7 +107,7 @@ impl Config { ini = self.global.clone().unwrap(); } ini.set(section, key, Some(value)); - if local{ + if local { self.local = Some(ini); } else { self.global = Some(ini); diff --git a/src/main.rs b/src/main.rs index 9e33d24..4408e45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ fn main() { match arg.as_str() { "-h" | "--help" => { - println!("open v0.4.0 + println!("open v0.5.0 Valerie Wolfe A Linux implementation of the \"open\" command on Mac OS written in Rust and easily configurable. @@ -106,7 +106,7 @@ FLAGS: let i_exe = config.get(ext, "command"); if i_exe.is_none() { let use_editor = config.getbool("open", "use_editor"); - if use_editor.is_ok() && use_editor.ok().unwrap().unwrap() { + if use_editor.unwrap_or(false) { let i_editor = var("EDITOR"); if i_editor.is_err() { println!("open: encountered an error trying to access $EDITOR"); @@ -143,7 +143,7 @@ FLAGS: command.args(param) .current_dir(dir); - let is_sh = config.getbool(ext, "shell").ok().unwrap_or(Some(false)).unwrap_or(false); + let is_sh = config.getbool(ext, "shell").unwrap_or(false); if is_sh { command.stdout(Stdio::inherit()) .stderr(Stdio::inherit())