summaryrefslogtreecommitdiffstats
path: root/src/worker.rs
diff options
context:
space:
mode:
authorDaniel Luz <dev@mernen.com>2016-11-19 21:48:59 -0200
committerDaniel Luz <dev@mernen.com>2016-11-19 21:48:59 -0200
commitbd3e7eedb1d8698a46e18afd2041e675f6597947 (patch)
tree327d6c6f2f30174ae754232480bc656ac5713105 /src/worker.rs
parent1e6c2ac8e374c9f45204ecce1ddd96842ed26d15 (diff)
Add --files-without-matches flag.
Performs the opposite of --files-with-matches: only shows paths of files that contain zero matches. Closes #138
Diffstat (limited to 'src/worker.rs')
-rw-r--r--src/worker.rs12
1 files changed, 12 insertions, 0 deletions
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)