cli: add -. as short option for --hidden

This is somewhat non-standard, but it seems nice on the surface: short
flag names are in short supply, --hidden is probably somewhat common and
-. has an obvious connection with how hidden files are named on Unix.

Closes #1680
This commit is contained in:
João Marcos 2020-09-10 20:32:54 -03:00 committed by Andrew Gallant
parent 12dd455ee9
commit 4566882521
5 changed files with 13 additions and 8 deletions

View File

@ -2,6 +2,8 @@ TBD
=== ===
Unreleased changes. Release notes have not yet been written. Unreleased changes. Release notes have not yet been written.
**BREAKING CHANGES**:
In this release, a small tweak has been made to the output format when a binary In this release, a small tweak has been made to the output format when a binary
file is detected. Previously, it looked like this: file is detected. Previously, it looked like this:
@ -31,6 +33,8 @@ Feature enhancements:
minified files, Mint, pofiles (from GNU gettext) Racket, VCL, Yang minified files, Mint, pofiles (from GNU gettext) Racket, VCL, Yang
* [FEATURE #1404](https://github.com/BurntSushi/ripgrep/pull/1404): * [FEATURE #1404](https://github.com/BurntSushi/ripgrep/pull/1404):
ripgrep now prints a warning if nothing is searched. ripgrep now prints a warning if nothing is searched.
* [FEATURE #1680](https://github.com/BurntSushi/ripgrep/pull/1680):
Add `-.` as a short flag alias for `--hidden`.
* [FEATURE #1856](https://github.com/BurntSushi/ripgrep/pull/1856): * [FEATURE #1856](https://github.com/BurntSushi/ripgrep/pull/1856):
The README now links to a The README now links to a
[Spanish translation](https://github.com/UltiRequiem/traducciones/tree/master/ripgrep). [Spanish translation](https://github.com/UltiRequiem/traducciones/tree/master/ripgrep).

View File

@ -44,8 +44,8 @@ main() {
# Occasionally we may have to handle some manually, however # Occasionally we may have to handle some manually, however
help_args=( ${(f)"$( help_args=( ${(f)"$(
$rg --help | $rg --help |
$rg -i -- '^\s+--?[a-z0-9]|--[a-z]' | $rg -i -- '^\s+--?[a-z0-9.]|--[a-z]' |
$rg -ior '$1' -- $'[\t /\"\'`.,](-[a-z0-9]|--[a-z0-9-]+)\\b' | $rg -ior '$1' -- $'[\t /\"\'`.,](-[a-z0-9.]|--[a-z0-9-]+)(,|\\b)' |
$rg -v -- --print0 | # False positives $rg -v -- --print0 | # False positives
sort -u sort -u
)"} ) )"} )

View File

@ -121,7 +121,7 @@ _rg() {
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]" "(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
+ '(hidden)' # Hidden-file options + '(hidden)' # Hidden-file options
'--hidden[search hidden files and directories]' {-.,--hidden}'[search hidden files and directories]'
$no"--no-hidden[don't search hidden files and directories]" $no"--no-hidden[don't search hidden files and directories]"
+ '(hybrid)' # hybrid regex options + '(hybrid)' # hybrid regex options

View File

@ -1452,6 +1452,7 @@ This flag can be disabled with --no-hidden.
" "
); );
let arg = RGArg::switch("hidden") let arg = RGArg::switch("hidden")
.short(".")
.help(SHORT) .help(SHORT)
.long_help(LONG) .long_help(LONG)
.overrides("no-hidden"); .overrides("no-hidden");
@ -1987,7 +1988,7 @@ fn flag_no_ignore_dot(args: &mut Vec<RGArg>) {
Don't respect .ignore files. Don't respect .ignore files.
This does *not* affect whether ripgrep will ignore files and directories This does *not* affect whether ripgrep will ignore files and directories
whose names begin with a dot. For that, see --hidden. whose names begin with a dot. For that, see the -./--hidden flag.
This flag can be disabled with the --ignore-dot flag. This flag can be disabled with the --ignore-dot flag.
" "
@ -2360,7 +2361,7 @@ the empty string. For example, if you are searching using 'rg foo' then using
occurrences of 'foo' will be highlighted. This flag enables the same behavior occurrences of 'foo' will be highlighted. This flag enables the same behavior
without needing to modify the pattern. without needing to modify the pattern.
This overrides the --context, --after-context and --before context flags. This overrides the --context, --after-context and --before-context flags.
" "
); );
let arg = RGArg::switch("passthru") let arg = RGArg::switch("passthru")
@ -2990,8 +2991,8 @@ fn flag_unrestricted(args: &mut Vec<RGArg>) {
"\ "\
Reduce the level of \"smart\" searching. A single -u won't respect .gitignore Reduce the level of \"smart\" searching. A single -u won't respect .gitignore
(etc.) files (--no-ignore). Two -u flags will additionally search hidden files (etc.) files (--no-ignore). Two -u flags will additionally search hidden files
and directories (--hidden). Three -u flags will additionally search binary files and directories (-./--hidden). Three -u flags will additionally search binary
(--binary). files (--binary).
'rg -uuu' is roughly equivalent to 'grep -r'. 'rg -uuu' is roughly equivalent to 'grep -r'.
" "

View File

@ -166,7 +166,7 @@ Each of the types of filtering can be configured via command line flags:
* There are several flags starting with '--no-ignore' that toggle which, * There are several flags starting with '--no-ignore' that toggle which,
if any, ignore rules are respected. '--no-ignore' by itself will disable if any, ignore rules are respected. '--no-ignore' by itself will disable
all of them. all of them.
* '--hidden' will force ripgrep to search hidden files and directories. * '-./--hidden' will force ripgrep to search hidden files and directories.
* '--binary' will force ripgrep to search binary files. * '--binary' will force ripgrep to search binary files.
* '-L/--follow' will force ripgrep to follow symlinks. * '-L/--follow' will force ripgrep to follow symlinks.