add --iglob flag

Working with Chris Stadler, implemented
https://github.com/BurntSushi/ripgrep/issues/163#issuecomment-300012592
This commit is contained in:
Peter S Panov
2017-06-29 00:57:33 +00:00
committed by Andrew Gallant
parent 4683a325fa
commit 4047d9db71
5 changed files with 96 additions and 0 deletions

View File

@@ -90,6 +90,9 @@ pub fn app() -> App<'static, 'static> {
.arg(flag("glob").short("g")
.takes_value(true).multiple(true).number_of_values(1)
.value_name("GLOB"))
.arg(flag("iglob")
.takes_value(true).multiple(true).number_of_values(1)
.value_name("GLOB"))
.arg(flag("ignore-case").short("i"))
.arg(flag("line-number").short("n"))
.arg(flag("no-line-number").short("N").overrides_with("line-number"))
@@ -270,6 +273,13 @@ lazy_static! {
ignore logic. Multiple glob flags may be used. Globbing \
rules match .gitignore globs. Precede a glob with a ! \
to exclude it.");
doc!(h, "iglob",
"Include or exclude files/directories case insensitively.",
"Include or exclude files/directories for searching that \
match the given glob. This always overrides any other \
ignore logic. Multiple glob flags may be used. Globbing \
rules match .gitignore globs. Precede a glob with a ! \
to exclude it. Globs are matched case insensitively.");
doc!(h, "ignore-case",
"Case insensitive search.",
"Case insensitive search. This is overridden by \

View File

@@ -771,6 +771,14 @@ impl<'a> ArgMatches<'a> {
for glob in self.values_of_lossy_vec("glob") {
try!(ovr.add(&glob));
}
// this is smelly. In the long run it might make sense
// to change overridebuilder to be like globsetbuilder
// but this would be a breaking change to the ignore crate
// so it is being shelved for now...
try!(ovr.case_insensitive(true));
for glob in self.values_of_lossy_vec("iglob") {
try!(ovr.add(&glob));
}
ovr.build().map_err(From::from)
}