summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2020-03-12 19:04:47 -0300
committerGitHub <noreply@github.com>2020-03-12 19:04:47 -0300
commite32e0f12455bdd1e30b7ef5bb2f1616b3123157a (patch)
tree98368c00a40c2afde5d1546ffe2aab80797e8167
parent8d0c82c8a2437f6f6667a44016ccea8e1f422fc0 (diff)
Fix delimiter (#239)v2.0.8
Fixes #230
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/cheat.rs17
3 files changed, 14 insertions, 7 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1874236..0e2176b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -89,7 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "navi"
-version = "2.0.7"
+version = "2.0.8"
dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"raw_tty 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 5be37a1..5f6dc14 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "navi"
-version = "2.0.7"
+version = "2.0.8"
authors = ["Denis Isidoro <denis_isidoro@live.com>"]
edition = "2018"
diff --git a/src/cheat.rs b/src/cheat.rs
index 5789894..9aeafee 100644
--- a/src/cheat.rs
+++ b/src/cheat.rs
@@ -24,6 +24,10 @@ fn gen_snippet(snippet: &str, line: &str) -> String {
}
}
+fn remove_quote(txt: &str) -> String {
+ txt.replace('"', "").replace('\'', "")
+}
+
fn parse_opts(text: &str) -> SuggestionOpts {
let mut header_lines: u8 = 0;
let mut column: Option<u8> = None;
@@ -36,10 +40,10 @@ fn parse_opts(text: &str) -> SuggestionOpts {
match p {
"--multi" => multi = true,
"--header" | "--headers" | "--header-lines" => {
- header_lines = parts.next().unwrap().parse::<u8>().unwrap()
+ header_lines = remove_quote(parts.next().unwrap()).parse::<u8>().unwrap()
}
- "--column" => column = Some(parts.next().unwrap().parse::<u8>().unwrap()),
- "--delimiter" => delimiter = Some(parts.next().unwrap().to_string()),
+ "--column" => column = Some(remove_quote(parts.next().unwrap()).parse::<u8>().unwrap()),
+ "--delimiter" => delimiter = Some(remove_quote(parts.next().unwrap()).to_string()),
_ => (),
}
}
@@ -134,8 +138,11 @@ fn read_file(
pub fn read_all(config: &Config, stdin: &mut std::process::ChildStdin) -> HashMap<String, Value> {
let mut variables: HashMap<String, Value> = HashMap::new();
- let fallback = filesystem::pathbuf_to_string(filesystem::cheat_pathbuf().unwrap());
- let folders_str = config.path.as_ref().unwrap_or(&fallback);
+ let mut fallback: String = String::from("");
+ let folders_str = config.path.as_ref().unwrap_or_else(|| {
+ fallback = filesystem::pathbuf_to_string(filesystem::cheat_pathbuf().unwrap());
+ &fallback
+ });
let folders = folders_str.split(':');
for folder in folders {