From d375b5e1f5eeb2ddd9d05f6366696a67d8db4523 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Thu, 13 Sep 2018 11:19:17 -0500 Subject: [PATCH] Add `--maxdepth` as hidden alias for `--max-depth` 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. --- src/app.rs | 10 ++++++++++ src/main.rs | 1 + 2 files changed, 11 insertions(+) diff --git a/src/app.rs b/src/app.rs index 7496b5c..d951cca 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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") @@ -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 \ diff --git a/src/main.rs b/src/main.rs index 0de41f5..1835f32 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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