From 945698353611dffb053370eeb251599d012f6d26 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 5 Jul 2021 13:34:37 -0400 Subject: [PATCH] added path flag --- Cargo.toml | 2 +- src/config.rs | 4 ++-- src/main.rs | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2baa15b..71f9cc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "open" -version = "0.3.0" +version = "0.3.1" authors = ["Valerie Wolfe "] edition = "2018" diff --git a/src/config.rs b/src/config.rs index b004fb5..1070ec6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,8 +9,8 @@ use configparser::ini::Ini; pub struct Config { pub local: Option, pub global: Option, - local_path: Option, - global_path: Option + pub local_path: Option, + pub global_path: Option } impl Config { diff --git a/src/main.rs b/src/main.rs index c31d7f4..5df0c6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,8 +30,9 @@ USAGE: open [FLAGS] [OPERAND] FLAGS: - -h, --help Prints this help text - -a, --add Add a handler for a operand type + -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());