diff --git a/complete/_rg b/complete/_rg index f91a31bc..0d5940cc 100644 --- a/complete/_rg +++ b/complete/_rg @@ -51,7 +51,8 @@ _rg() { '(-M --max-columns)'{-M+,--max-columns=}'[specify max length of lines to print]:number of bytes' '(-m --max-count)'{-m+,--max-count=}'[specify max number of matches per file]:number of matches' '--max-filesize=[specify size above which files should be ignored]:file size' - '--maxdepth=[specify max number of directories to descend]:number of directories' + '--max-depth=[specify max number of directories to descend]:number of directories' + '!--maxdepth=:number of directories' '(--mmap --no-mmap)--mmap[search using memory maps when possible]' '(-H --with-filename --no-filename)--no-filename[suppress all file names]' "(-p --heading --pretty --vimgrep)--no-heading[don't group matches by file name]" diff --git a/src/app.rs b/src/app.rs index 94c3b599..5728371f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -521,8 +521,8 @@ pub fn all_args_and_flags() -> Vec { flag_line_regexp(&mut args); flag_max_columns(&mut args); flag_max_count(&mut args); + flag_max_depth(&mut args); flag_max_filesize(&mut args); - flag_maxdepth(&mut args); flag_mmap(&mut args); flag_no_config(&mut args); flag_no_ignore(&mut args); @@ -1130,6 +1130,23 @@ Limit the number of matching lines per file searched to NUM. args.push(arg); } +fn flag_max_depth(args: &mut Vec) { + const SHORT: &str = "Descend at most NUM directories."; + const LONG: &str = long!("\ +Limit the depth of directory traversal to NUM levels beyond the paths given. A +value of zero only searches the explicitly given paths themselves. + +For example, 'rg --max-depth 0 dir/' is a no-op because dir/ will not be +descended into. 'rg --max-depth 1 dir/' will search only the direct children of +'dir'. +"); + let arg = RGArg::flag("max-depth", "NUM") + .help(SHORT).long_help(LONG) + .alias("maxdepth") + .number(); + args.push(arg); +} + fn flag_max_filesize(args: &mut Vec) { const SHORT: &str = "Ignore files larger than NUM in size."; const LONG: &str = long!("\ @@ -1146,22 +1163,6 @@ Examples: --max-filesize 50K or --max-filesize 80M args.push(arg); } -fn flag_maxdepth(args: &mut Vec) { - const SHORT: &str = "Descend at most NUM directories."; - const LONG: &str = long!("\ -Limit the depth of directory traversal to NUM levels beyond the paths given. A -value of zero only searches the explicitly given paths themselves. - -For example, 'rg --maxdepth 0 dir/' is a no-op because dir/ will not be -descended into. 'rg --maxdepth 1 dir/' will search only the direct children of -'dir'. -"); - let arg = RGArg::flag("maxdepth", "NUM") - .help(SHORT).long_help(LONG) - .number(); - args.push(arg); -} - fn flag_mmap(args: &mut Vec) { const SHORT: &str = "Search using memory maps when possible."; const LONG: &str = long!("\ diff --git a/src/args.rs b/src/args.rs index e410cd7c..aca9bcd5 100644 --- a/src/args.rs +++ b/src/args.rs @@ -58,8 +58,8 @@ pub struct Args { line_per_match: bool, max_columns: Option, max_count: Option, + max_depth: Option, max_filesize: Option, - maxdepth: Option, mmap: bool, no_ignore: bool, no_ignore_messages: bool, @@ -345,7 +345,7 @@ impl Args { wd.follow_links(self.follow); wd.hidden(!self.hidden); - wd.max_depth(self.maxdepth); + wd.max_depth(self.max_depth); wd.max_filesize(self.max_filesize); wd.overrides(self.glob_overrides.clone()); wd.types(self.types.clone()); @@ -407,8 +407,8 @@ impl<'a> ArgMatches<'a> { line_per_match: self.is_present("vimgrep"), max_columns: self.usize_of_nonzero("max-columns")?, max_count: self.usize_of("max-count")?.map(|n| n as u64), + max_depth: self.usize_of("max-depth")?, max_filesize: self.max_filesize()?, - maxdepth: self.usize_of("maxdepth")?, mmap: mmap, no_ignore: self.no_ignore(), no_ignore_messages: self.is_present("no-ignore-messages"),