From bd3e7eedb1d8698a46e18afd2041e675f6597947 Mon Sep 17 00:00:00 2001 From: Daniel Luz Date: Sat, 19 Nov 2016 21:48:59 -0200 Subject: Add --files-without-matches flag. Performs the opposite of --files-with-matches: only shows paths of files that contain zero matches. Closes #138 --- src/worker.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/worker.rs') diff --git a/src/worker.rs b/src/worker.rs index 0ade140a..23ed7549 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -31,6 +31,7 @@ struct Options { before_context: usize, count: bool, files_with_matches: bool, + files_without_matches: bool, eol: u8, invert_match: bool, line_number: bool, @@ -48,6 +49,7 @@ impl Default for Options { before_context: 0, count: false, files_with_matches: false, + files_without_matches: false, eol: b'\n', invert_match: false, line_number: false, @@ -112,6 +114,14 @@ impl WorkerBuilder { self } + /// If enabled, searching will print the path of files without any matches. + /// + /// Disabled by default. + pub fn files_without_matches(mut self, yes: bool) -> Self { + self.opts.files_without_matches = yes; + self + } + /// Set the end-of-line byte used by this searcher. pub fn eol(mut self, eol: u8) -> Self { self.opts.eol = eol; @@ -230,6 +240,7 @@ impl Worker { .before_context(self.opts.before_context) .count(self.opts.count) .files_with_matches(self.opts.files_with_matches) + .files_without_matches(self.opts.files_without_matches) .eol(self.opts.eol) .line_number(self.opts.line_number) .invert_match(self.opts.invert_match) @@ -260,6 +271,7 @@ impl Worker { Ok(searcher .count(self.opts.count) .files_with_matches(self.opts.files_with_matches) + .files_without_matches(self.opts.files_without_matches) .eol(self.opts.eol) .line_number(self.opts.line_number) .invert_match(self.opts.invert_match) -- cgit v1.2.3