added path flag

This commit is contained in:
Valerie Wolfe 2021-07-05 13:34:37 -04:00
parent c99ef1a7b0
commit 9456983536
3 changed files with 17 additions and 6 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "open" name = "open"
version = "0.3.0" version = "0.3.1"
authors = ["Valerie Wolfe <sleeplessval@gmail.com>"] authors = ["Valerie Wolfe <sleeplessval@gmail.com>"]
edition = "2018" edition = "2018"

View file

@ -9,8 +9,8 @@ use configparser::ini::Ini;
pub struct Config { pub struct Config {
pub local: Option<Ini>, pub local: Option<Ini>,
pub global: Option<Ini>, pub global: Option<Ini>,
local_path: Option<String>, pub local_path: Option<String>,
global_path: Option<String> pub global_path: Option<String>
} }
impl Config { impl Config {

View file

@ -32,6 +32,7 @@ USAGE:
FLAGS: FLAGS:
-h, --help Prints this help text -h, --help Prints this help text
-a, --add Add a handler for a operand type -a, --add Add a handler for a operand type
-p, --path Prints the config path used
"); ");
return; return;
}, },
@ -52,7 +53,17 @@ FLAGS:
} }
config.write().ok(); config.write().ok();
return; return;
},
"-p" |
"--path" => {
let local = config.local_path;
if local.is_some() {
println!("{}", local.unwrap());
} else {
println!("{}", config.global_path.unwrap());
} }
return;
},
_ => { _ => {
if file_operand { if file_operand {
error = Some("open: too many file operands.".to_string()); error = Some("open: too many file operands.".to_string());