Skip to content

Commit

Permalink
Add --maxdepth as hidden alias for --max-depth
Browse files Browse the repository at this point in the history
For muscle memory compatibility with `rg`. This variant will not show in
the help or in the program options, and is only checked if `--maxdepth`
is not specified.
  • Loading branch information
mqudsi authored and sharkdp committed Sep 13, 2018
1 parent 2465cd1 commit ee2f13f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ pub fn build_app() -> App<'static, 'static> {
.arg(arg("full-path").long("full-path").short("p"))
.arg(arg("null_separator").long("print0").short("0"))
.arg(arg("depth").long("max-depth").short("d").takes_value(true))
// support --maxdepth as well, for compatibility with rg
.arg(
arg("rg-depth")
.long("maxdepth")
.hidden(true)
.takes_value(true),
).arg(
arg("file-type")
.long("type")
.short("t")
Expand Down Expand Up @@ -197,6 +203,10 @@ fn usage() -> HashMap<&'static str, Help> {
, "Set maximum search depth (default: none)"
, "Limit the directory traversal to a given depth. By default, there is no limit \
on the search depth.");
doc!(h, "rg-depth"
, "Set maximum search depth (default: none)"
, "Limit the directory traversal to a given depth. By default, there is no limit \
on the search depth.");
doc!(h, "file-type"
, "Filter by type: file (f), directory (d), symlink (l),\nexecutable (x), empty (e)"
, "Filter the search by type (multiple allowable filetypes can be specified):\n \
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ fn main() {
null_separator: matches.is_present("null_separator"),
max_depth: matches
.value_of("depth")
.or_else(|| matches.value_of("rg-depth"))
.and_then(|n| usize::from_str_radix(n, 10).ok()),
threads: std::cmp::max(
matches
Expand Down

0 comments on commit ee2f13f

Please sign in to comment.