1
0
mirror of https://github.com/sharkdp/fd synced 2024-07-03 00:08:39 +00:00

Improve --extension help text, closes #673

This commit is contained in:
sharkdp 2020-12-06 12:20:50 +01:00
parent d205a7ff9e
commit d2659de782
3 changed files with 34 additions and 1 deletions

3
doc/fd.1 vendored
View File

@ -145,6 +145,9 @@ This option can be used repeatedly to allow for multiple file types.
Filter search results by file extension
.IR ext .
This option can be used repeatedly to allow for multiple possible file extensions.
If you want to search for files without extension, you can use the regex '^[^.]+$'
as a normal search pattern.
.TP
.BI "\-E, \-\-exclude " pattern
Exclude files/directories that match the given glob pattern.

View File

@ -279,7 +279,9 @@ pub fn build_app() -> App<'static, 'static> {
.help("Filter by file extension")
.long_help(
"(Additionally) filter search results by their file extension. Multiple \
allowable file extensions can be specified.",
allowable file extensions can be specified.\n\
If you want to search for files without extension, \
you can use the regex '^[^.]+$' as a normal search pattern.",
),
)
.arg(

View File

@ -1016,6 +1016,34 @@ fn test_extension() {
te4.assert_output(&["--hidden", "--extension", ".hidden"], "test.hidden");
}
/// No file extension (test for the pattern provided in the --help text)
#[test]
fn test_no_extension() {
let te = TestEnv::new(
DEFAULT_DIRS,
&["a.foo", "aa", "one/b.foo", "one/bb", "one/two/three/d"],
);
te.assert_output(
&["^[^.]+$"],
"aa
one
one/bb
one/two
one/two/three
one/two/three/d
one/two/three/directory_foo
symlink",
);
te.assert_output(
&["^[^.]+$", "--type", "file"],
"aa
one/bb
one/two/three/d",
);
}
/// Symlink as search directory
#[test]
fn test_symlink_as_root() {