diff options
author | Andrew Gallant <jamslam@gmail.com> | 2016-11-06 14:36:08 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2016-11-06 14:36:08 -0500 |
commit | 77ad7588ae191c8216f0696dad1996c4d0dd561b (patch) | |
tree | 776ba84180f434d830663bf78e7e4bda413a9200 /src/worker.rs | |
parent | 58aca2efb24801b43870acac5b40c59fbc9ef350 (diff) |
Add --no-messages flag.
This flag is similar to what's found in grep: it will suppress all error
messages, such as those shown when a particular file couldn't be read.
Closes #149
Diffstat (limited to 'src/worker.rs')
-rw-r--r-- | src/worker.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/worker.rs b/src/worker.rs index bc8a62b3..0ade140a 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -35,6 +35,7 @@ struct Options { invert_match: bool, line_number: bool, max_count: Option<u64>, + no_messages: bool, quiet: bool, text: bool, } @@ -51,6 +52,7 @@ impl Default for Options { invert_match: false, line_number: false, max_count: None, + no_messages: false, quiet: false, text: false, } @@ -186,7 +188,9 @@ impl Worker { let file = match File::open(path) { Ok(file) => file, Err(err) => { - eprintln!("{}: {}", path.display(), err); + if !self.opts.no_messages { + eprintln!("{}: {}", path.display(), err); + } return 0; } }; @@ -205,7 +209,9 @@ impl Worker { count } Err(err) => { - eprintln!("{}", err); + if !self.opts.no_messages { + eprintln!("{}", err); + } 0 } } |