From c15d3215dea3dadf93c1be1291c4001c3bff8f4e Mon Sep 17 00:00:00 2001 From: Joursoir Date: Thu, 2 Mar 2023 23:57:15 +0400 Subject: add option to ignore search string case --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index af3b56a..3111766 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,10 @@ struct Config { /// /// If no FILE is given, read standard input. files: Vec, + + /// Ignores the case of the search string + #[arg(short, long)] + ignore_case: bool, } fn main() { @@ -43,7 +47,10 @@ fn run(config: Config) -> Result<(), Box> { &mut file_read }; - for line in reader.lines().map(|l| l.unwrap().contains(&config.pattern)) { + for line in reader.lines().map(|l| l.unwrap()) { + if !trgrep::contains_pattern(&line, &config.pattern, config.ignore_case) { + continue; + } println!("{line}"); } } -- cgit v1.2.3-18-g5258