From e124c5223229f6ebf8a32b570570045f6d95b58f Mon Sep 17 00:00:00 2001 From: Rav Chandra Date: Thu, 12 Oct 2017 00:07:50 +1300 Subject: [PATCH 1/2] Add ripgrep aliases for no-ignore and hidden --- src/app.rs | 4 ++++ src/main.rs | 4 ++-- tests/tests.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index ceaf6d541..89dac0642 100644 --- a/src/app.rs +++ b/src/app.rs @@ -34,6 +34,7 @@ pub fn build_app() -> App<'static, 'static> { .setting(AppSettings::DeriveDisplayOrder) .arg(arg("hidden").long("hidden").short("H")) .arg(arg("no-ignore").long("no-ignore").short("I")) + .arg(arg("rg-alias-hidden-ignore").short("u").multiple(true).hidden(true)) .arg(arg("case-sensitive").long("case-sensitive").short("s")) .arg(arg("absolute-path").long("absolute-path").short("a")) .arg(arg("follow").long("follow").short("L").alias("dereference")) @@ -144,6 +145,9 @@ fn usage() -> HashMap<&'static str, Help> { , "the root directory for the filesystem search (optional)" , "The directory where the filesystem search is rooted (optional). \ If omitted, search the current working directory."); + doc!(h, "rg-alias-hidden-ignore" + , "Alias for no-ignore and/or hidden" + , "Alias for no-ignore ('u') and no-ignore and hidden ('uu')"); h } diff --git a/src/main.rs b/src/main.rs index fc561048b..34879d795 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,8 +86,8 @@ fn main() { let config = FdOptions { case_sensitive: case_sensitive, search_full_path: matches.is_present("full-path"), - ignore_hidden: !matches.is_present("hidden"), - read_ignore: !matches.is_present("no-ignore"), + ignore_hidden: !(matches.is_present("hidden") || matches.occurrences_of("rg-alias-hidden-ignore") == 2), + read_ignore: !(matches.is_present("no-ignore") || matches.is_present("rg-alias-hidden-ignore")), follow_links: matches.is_present("follow"), null_separator: matches.is_present("null_separator"), max_depth: matches.value_of("depth") diff --git a/tests/tests.rs b/tests/tests.rs index 6ac284a60..ec1039190 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -175,6 +175,33 @@ fn test_no_ignore() { one/two/three/directory_foo"); } +/// Ignored files with ripgrep aliases (-u / -uu) +#[test] +fn test_no_ignore_aliases() { + let te = TestEnv::new(); + + te.assert_output( + &["-u", "foo"], + "a.foo + ignored.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo"); + + te.assert_output( + &["-uu", "foo"], + ".hidden.foo + a.foo + ignored.foo + one/b.foo + one/two/c.foo + one/two/C.Foo2 + one/two/three/d.foo + one/two/three/directory_foo"); +} + /// Symlinks (--follow) #[test] fn test_follow() { From 749d25f517590e123d37e6af3a2844897e47cf71 Mon Sep 17 00:00:00 2001 From: Rav Chandra Date: Thu, 12 Oct 2017 09:28:47 +1300 Subject: [PATCH 2/2] liberally accept >2 -u options as per ripgrep --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 34879d795..49eb74128 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,7 +86,7 @@ fn main() { let config = FdOptions { case_sensitive: case_sensitive, search_full_path: matches.is_present("full-path"), - ignore_hidden: !(matches.is_present("hidden") || matches.occurrences_of("rg-alias-hidden-ignore") == 2), + ignore_hidden: !(matches.is_present("hidden") || matches.occurrences_of("rg-alias-hidden-ignore") >= 2), read_ignore: !(matches.is_present("no-ignore") || matches.is_present("rg-alias-hidden-ignore")), follow_links: matches.is_present("follow"), null_separator: matches.is_present("null_separator"),