summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2023-11-21 18:07:18 -0500
committerAndrew Gallant <jamslam@gmail.com>2023-11-21 18:39:32 -0500
commitaf55fc2b38cc5d31e24f3392ec2d03ab5f6428c4 (patch)
tree872de6123edd19ecc4667a6990db137e53b4e46a
parent3d2f49f6fe70a61fa501c3ed95d208ef10d3b94d (diff)
cli: make -d a short flag for --max-depth
Interestingly, ripgrep now only has two available ASCII letter short flags remaining: -k and -y. Closes #2643, Closes #2644
-rw-r--r--CHANGELOG.md2
-rw-r--r--crates/core/flags/complete/rg.zsh2
-rw-r--r--crates/core/flags/defs.rs6
3 files changed, 9 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a2943dc..d8c7e6ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,8 @@ Feature enhancements:
When `extra-verbose` mode is enabled in zsh, show extra file type info.
* [FEATURE #2409](https://github.com/BurntSushi/ripgrep/pull/2409):
Added installation instructions for `winget`.
+* [FEATURE #2643](https://github.com/BurntSushi/ripgrep/issues/2643):
+ Make `-d` a short flag for `--max-depth`.
Bug fixes:
diff --git a/crates/core/flags/complete/rg.zsh b/crates/core/flags/complete/rg.zsh
index 0d44ce7d..7ca89008 100644
--- a/crates/core/flags/complete/rg.zsh
+++ b/crates/core/flags/complete/rg.zsh
@@ -192,7 +192,7 @@ _rg() {
$no"--no-max-columns-preview[don't show preview for long lines (with -M)]"
+ '(max-depth)' # Directory-depth options
- '--max-depth=[specify max number of directories to descend]:number of directories'
+ {-d,--max-depth}'[specify max number of directories to descend]:number of directories'
'--maxdepth=[alias for --max-depth]:number of directories'
'!--maxdepth=:number of directories'
diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs
index 8f0cbd88..ed78c28a 100644
--- a/crates/core/flags/defs.rs
+++ b/crates/core/flags/defs.rs
@@ -3829,6 +3829,9 @@ impl Flag for MaxDepth {
fn is_switch(&self) -> bool {
false
}
+ fn name_short(&self) -> Option<u8> {
+ Some(b'd')
+ }
fn name_long(&self) -> &'static str {
"max-depth"
}
@@ -3873,6 +3876,9 @@ fn test_max_depth() {
let args = parse_low_raw(["--max-depth", "5"]).unwrap();
assert_eq!(Some(5), args.max_depth);
+ let args = parse_low_raw(["-d", "5"]).unwrap();
+ assert_eq!(Some(5), args.max_depth);
+
let args = parse_low_raw(["--max-depth", "5", "--max-depth=10"]).unwrap();
assert_eq!(Some(10), args.max_depth);