summaryrefslogtreecommitdiffstats
path: root/src/app.rs
diff options
context:
space:
mode:
authorCollin Styles <collingstyles@gmail.com>2019-10-16 19:03:00 -0700
committerAndrew Gallant <jamslam@gmail.com>2020-02-17 17:16:28 -0500
commita070722ff27c7d57d47b1766de9d253fbfe5bef9 (patch)
tree1a6370a1966bc094f22ef2d61afcb9d4c1ad6d52 /src/app.rs
parent4628d778089d0bf609462af7d5b38997fd9a014f (diff)
cli: add --include-zero flag
This flag, when used in conjunction with --count or --count-matches, will print a result for each file searched even if there were zero matches in that file. This is off by default but can be enabled to make ripgrep behave more like grep. This also clarifies some of the defaults for the grep-printer::SummaryBuilder type. Closes #1370, Closes #1405
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/app.rs b/src/app.rs
index cd4a927b..ae26f0c6 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -578,6 +578,7 @@ pub fn all_args_and_flags() -> Vec<RGArg> {
flag_ignore_case(&mut args);
flag_ignore_file(&mut args);
flag_ignore_file_case_insensitive(&mut args);
+ flag_include_zero(&mut args);
flag_invert_match(&mut args);
flag_json(&mut args);
flag_line_buffered(&mut args);
@@ -1373,6 +1374,17 @@ This flag can be disabled with the --no-ignore-file-case-insensitive flag.
args.push(arg);
}
+fn flag_include_zero(args: &mut Vec<RGArg>) {
+ const SHORT: &str = "Include files with zero matches in summary";
+ const LONG: &str = long!("\
+When used with --count or --count-matches, print the number of matches for
+each file even if there were zero matches. This is disabled by default but can
+be enabled to make ripgrep behave more like grep.
+");
+ let arg = RGArg::switch("include-zero").help(SHORT).long_help(LONG);
+ args.push(arg);
+}
+
fn flag_invert_match(args: &mut Vec<RGArg>) {
const SHORT: &str = "Invert matching.";
const LONG: &str = long!("\