From ed835ae90ea9f62dca0ac45adb7c4b0e0454da23 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 1 May 2020 14:38:37 +0200 Subject: 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. --- src/main.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/main.rs') 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(()) -- cgit v1.2.3