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]
name = "open"
version = "0.3.0"
version = "0.3.1"
authors = ["Valerie Wolfe <sleeplessval@gmail.com>"]
edition = "2018"

View file

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

View file

@ -32,6 +32,7 @@ USAGE:
FLAGS:
-h, --help Prints this help text
-a, --add Add a handler for a operand type
-p, --path Prints the config path used
");
return;
},
@ -52,7 +53,17 @@ FLAGS:
}
config.write().ok();
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 {
error = Some("open: too many file operands.".to_string());