From 23e51da3c9e2031810f68242fee2196bc1540a61 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 12 May 2017 12:09:46 +0200 Subject: [PATCH] Add case-sensitive flag, closes #9 --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d1e2853..5e979b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,6 +56,7 @@ fn main() { let mut opts = Options::new(); opts.optflag("h", "help", "print this help message"); + opts.optflag("s", "sensitive", "case-sensitive search"); let matches = match opts.parse(&args[1..]) { Ok(m) => { m } Err(f) => { error(&f) } @@ -67,6 +68,8 @@ fn main() { process::exit(1); } + let case_insensitive = !matches.opt_present("s"); + let empty = String::new(); let pattern = matches.free.get(0).unwrap_or(&empty); @@ -76,7 +79,7 @@ fn main() { match RegexBuilder::new(pattern) - .case_insensitive(true) + .case_insensitive(case_insensitive) .build() { Ok(re) => scan(current_dir, &re),