mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 13:01:30 +02:00
Add --regex option to override --glob
This commit is contained in:
parent
d5da615c17
commit
eac20a8132
11
src/app.rs
11
src/app.rs
@ -73,6 +73,12 @@ pub fn build_app() -> App<'static, 'static> {
|
||||
.short("g")
|
||||
.conflicts_with("fixed-strings"),
|
||||
)
|
||||
.arg(
|
||||
arg("regex")
|
||||
.long("regex")
|
||||
.overrides_with("glob")
|
||||
.hidden_short_help(true),
|
||||
)
|
||||
.arg(
|
||||
arg("fixed-strings")
|
||||
.long("fixed-strings")
|
||||
@ -259,6 +265,9 @@ fn usage() -> HashMap<&'static str, Help> {
|
||||
doc!(h, "glob"
|
||||
, "Glob-based search (default: regular expression)"
|
||||
, "Perform a glob-based search instead of a regular expression search.");
|
||||
doc!(h, "regex"
|
||||
, "Perform a regex-based search"
|
||||
, "Perform a regular-expression based seach (default). This can be used to override --glob.");
|
||||
doc!(h, "fixed-strings"
|
||||
, "Treat the pattern as a literal string"
|
||||
, "Treat the pattern as a literal string instead of a regular expression.");
|
||||
@ -346,7 +355,7 @@ fn usage() -> HashMap<&'static str, Help> {
|
||||
, "Amount of time in milliseconds to buffer, before streaming the search results to \
|
||||
the console.");
|
||||
doc!(h, "pattern"
|
||||
, "the search pattern, a regular expression (optional)");
|
||||
, "the search pattern: a regular expression unless '--glob' is used (optional)");
|
||||
doc!(h, "path"
|
||||
, "the root directory for the filesystem search (optional)"
|
||||
, "The directory where the filesystem search is rooted (optional). \
|
||||
|
@ -313,6 +313,14 @@ fn test_glob_searches_with_extension() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Make sure that --regex overrides --glob
|
||||
#[test]
|
||||
fn test_regex_overrides_glob() {
|
||||
let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);
|
||||
|
||||
te.assert_output(&["--glob", "--regex", "Foo2$"], "one/two/C.Foo2");
|
||||
}
|
||||
|
||||
/// Full path search (--full-path)
|
||||
#[test]
|
||||
fn test_full_path() {
|
||||
|
Loading…
Reference in New Issue
Block a user