Skip to content

Commit

Permalink
cli: make -d a short flag for --max-depth
Browse files Browse the repository at this point in the history
Interestingly, ripgrep now only has two available ASCII letter short
flags remaining: -k and -y.

Closes #2643, Closes #2644
  • Loading branch information
BurntSushi committed Nov 21, 2023
1 parent 1e2a42b commit dba9bd1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion crates/core/flags/complete/rg.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 6 additions & 0 deletions crates/core/flags/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit dba9bd1

Please sign in to comment.