cli: print warning if nothing was searched

This was once part of ripgrep, but at some point, was unintentionally
removed. The value of this warning is that since ripgrep tries to be
"smart" by default, it can be surprising if it doesn't search certain
things. This warning covers the case when ripgrep searches *nothing*,
which happens somewhat more frequently than you might expect. e.g., If
you're searching within an ignore directory.

Note that for now, we only print this message when the user has not
supplied any explicit paths. It's not clear that we want to print this
otherwise, and in particular, it seems that the message shows up too
eagerly. e.g., 'rg foo does-not-exist' will both print an error about
'does-not-exist' not existing, *and* the message about no files being
searched, which seems annoying in this case. We can always refine this
logic later.

Fixes #1404, Closes #1762
This commit is contained in:
goto-engineering
2020-12-14 23:59:55 -08:00
committed by Andrew Gallant
parent 0f502a9439
commit e6cac8b119
5 changed files with 67 additions and 3 deletions

View File

@@ -392,7 +392,9 @@ rgtest!(r428_color_context_path, |dir: Dir, mut cmd: TestCommand| {
});
// See: https://github.com/BurntSushi/ripgrep/issues/428
rgtest!(r428_unrecognized_style, |_: Dir, mut cmd: TestCommand| {
rgtest!(r428_unrecognized_style, |dir: Dir, mut cmd: TestCommand| {
dir.create("file.txt", "Sherlock");
cmd.arg("--colors=match:style:").arg("Sherlock");
cmd.assert_err();