summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordana <dana@dana.is>2019-08-01 16:08:58 -0500
committerAndrew Gallant <jamslam@gmail.com>2019-08-01 17:08:58 -0400
commitc2cb0a4de4597c8f911c8ebece6aa0435ef5da6f (patch)
tree130944b7519d3a089444d0ec3695e21c12ec95f7 /src
parentadb9332f52b884c8b872d1c969a7841188fe3089 (diff)
ripgrep: add --glob-case-insensitive
This flag forces -g/--glob patterns to be treated case-insensitively, as with --iglob patterns. Fixes #1293
Diffstat (limited to 'src')
-rw-r--r--src/app.rs20
-rw-r--r--src/args.rs4
2 files changed, 24 insertions, 0 deletions
diff --git a/src/app.rs b/src/app.rs
index fa322817..d69d5cd7 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -571,6 +571,7 @@ pub fn all_args_and_flags() -> Vec<RGArg> {
flag_fixed_strings(&mut args);
flag_follow(&mut args);
flag_glob(&mut args);
+ flag_glob_case_insensitive(&mut args);
flag_heading(&mut args);
flag_hidden(&mut args);
flag_iglob(&mut args);
@@ -1218,6 +1219,25 @@ it.
args.push(arg);
}
+fn flag_glob_case_insensitive(args: &mut Vec<RGArg>) {
+ const SHORT: &str = "Process all glob patterns case insensitively.";
+ const LONG: &str = long!("\
+Process glob patterns given with the -g/--glob flag case insensitively. This
+effectively treats --glob as --iglob.
+
+This flag can be disabled with the --no-glob-case-insensitive flag.
+");
+ let arg = RGArg::switch("glob-case-insensitive")
+ .help(SHORT).long_help(LONG)
+ .overrides("no-glob-case-insensitive");
+ args.push(arg);
+
+ let arg = RGArg::switch("no-glob-case-insensitive")
+ .hidden()
+ .overrides("glob-case-insensitive");
+ args.push(arg);
+}
+
fn flag_heading(args: &mut Vec<RGArg>) {
const SHORT: &str = "Print matches grouped by each file.";
const LONG: &str = long!("\
diff --git a/src/args.rs b/src/args.rs
index cd217b4b..09f924dc 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -1268,6 +1268,10 @@ impl ArgMatches {
/// Builds the set of glob overrides from the command line flags.
fn overrides(&self) -> Result<Override> {
let mut builder = OverrideBuilder::new(env::current_dir()?);
+ // Make all globs case insensitive with --glob-case-insensitive.
+ if self.is_present("glob-case-insensitive") {
+ builder.case_insensitive(true).unwrap();
+ }
for glob in self.values_of_lossy_vec("glob") {
builder.add(&glob)?;
}