diff options
author | Daniel <kingdread@gmx.de> | 2020-05-01 14:38:37 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-05-01 14:38:52 +0200 |
commit | ed835ae90ea9f62dca0ac45adb7c4b0e0454da23 (patch) | |
tree | a52bcef88988930393efd72150549098441490c8 /src/main.rs | |
parent | 4479ceddd48ae062fa10879ceb199b771fa35add (diff) | |
download | raidgrep-ed835ae90ea9f62dca0ac45adb7c4b0e0454da23.tar.gz raidgrep-ed835ae90ea9f62dca0ac45adb7c4b0e0454da23.tar.bz2 raidgrep-ed835ae90ea9f62dca0ac45adb7c4b0e0454da23.zip |
improve requoting heuristic
First of all, this allows : to be part of a word. This has been added
because the account names start with a colon, so -player :Dunje should
work.
Furthermore, the re-quoting now also quotes strings that contain a .+*,
as those are characters usually used in regular expressions. A command
line like
raidgrep -- -player "G.dric"
should work, so we either have to re-quote words with a dot, or allow
the dot to be part of a (lexical) word as well. For now, we're
re-quoting it, but if it turns out to be too troublesome, we might
change that.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index 33b3c45..cb67968 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,6 @@ use std::str::FromStr; use anyhow::{anyhow, Error, Result}; use chrono::{DateTime, TimeZone, Utc}; use colored::Colorize; -use itertools::Itertools; use log::debug; use regex::Regex; use rustyline::Editor; @@ -284,17 +283,7 @@ fn single(opt: &Opt) -> Result<()> { return grep(opt, &*maybe_filter?); } - let expr_string = opt - .expression - .iter() - .map(|part| { - if part.contains(' ') { - format!(r#""{}""#, part) - } else { - part.into() - } - }) - .join(" "); + let expr_string = fexpr::requote(&opt.expression); let filter = build_filter(&expr_string)?; grep(&opt, &*filter)?; Ok(()) |