mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-20 14:43:47 -07:00
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
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user