ripgrep: add --pre-glob flag
The --pre-glob flag is like the --glob flag, except it applies to filtering files through the preprocessor instead of for search. This makes it possible to apply the preprocessor to only a small subset of files, which can greatly reduce the process overhead of using a preprocessor when searching large directories.
This commit is contained in:
12
src/args.rs
12
src/args.rs
@@ -285,6 +285,7 @@ impl Args {
|
||||
builder
|
||||
.json_stats(self.matches().is_present("json"))
|
||||
.preprocessor(self.matches().preprocessor())
|
||||
.preprocessor_globs(self.matches().preprocessor_globs()?)
|
||||
.search_zip(self.matches().is_present("search-zip"));
|
||||
Ok(builder.build(matcher, searcher, printer))
|
||||
}
|
||||
@@ -1323,6 +1324,17 @@ impl ArgMatches {
|
||||
Some(Path::new(path).to_path_buf())
|
||||
}
|
||||
|
||||
/// Builds the set of globs for filtering files to apply to the --pre
|
||||
/// flag. If no --pre-globs are available, then this always returns an
|
||||
/// empty set of globs.
|
||||
fn preprocessor_globs(&self) -> Result<Override> {
|
||||
let mut builder = OverrideBuilder::new(env::current_dir()?);
|
||||
for glob in self.values_of_lossy_vec("pre-glob") {
|
||||
builder.add(&glob)?;
|
||||
}
|
||||
Ok(builder.build()?)
|
||||
}
|
||||
|
||||
/// Parse the regex-size-limit argument option into a byte count.
|
||||
fn regex_size_limit(&self) -> Result<Option<usize>> {
|
||||
let r = self.parse_human_readable_size("regex-size-limit")?;
|
||||
|
||||
Reference in New Issue
Block a user