added -h/--help and -a/--add flags.

This commit is contained in:
Valerie Wolfe 2021-06-23 10:59:44 -04:00
parent 0eda793663
commit c99ef1a7b0
2 changed files with 8 additions and 11 deletions

View file

@ -58,13 +58,13 @@ impl Config {
// prepare path vars // prepare path vars
let global_path: Option<String>; let global_path: Option<String>;
if global.is_some() { if global.is_some() {
global_path = Some(i_dir_global.to_string()); global_path = Some(path_global.to_str().unwrap().to_string());
} else { } else {
global_path = None global_path = None
} }
let local_path: Option<String>; let local_path: Option<String>;
if local.is_some() { 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 { } else {
local_path = None; local_path = None;
} }
@ -116,13 +116,13 @@ impl Config {
global.set(section, key, Some(value)); global.set(section, key, Some(value));
self.global = Some(global); self.global = Some(global);
} }
pub fn write(&self) { pub fn write(&self) -> std::io::Result<()> {
let mut path = self.local_path.as_ref(); let mut path = self.local_path.as_ref();
if path.is_some() { if path.is_some() {
self.local.as_ref().unwrap().write(path.unwrap().as_str()).ok(); let result = self.local.as_ref().unwrap().write(path.unwrap().as_str());
return; return result;
} }
path = self.global_path.as_ref(); 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())
} }
} }

View file

@ -45,11 +45,12 @@ FLAGS:
let exe = args.get(3).unwrap(); let exe = args.get(3).unwrap();
let tmp = args.get(4); let tmp = args.get(4);
let shell = tmp.is_some() && tmp.unwrap() == "shell"; let shell = tmp.is_some() && tmp.unwrap() == "shell";
println!("{} {} {}", ext, exe, shell);
config.add(ext, "command", exe.to_string()); config.add(ext, "command", exe.to_string());
if shell { if shell {
config.add(ext, "shell", "true".to_string()); config.add(ext, "shell", "true".to_string());
} }
config.write(); config.write().ok();
return; return;
} }
_ => { _ => {
@ -122,7 +123,3 @@ FLAGS:
command.spawn().ok(); command.spawn().ok();
} }
} }
fn get_ext() {
}