From 867c53043b1be8af6a5c1f3fed10cd45796d4a0a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 10 Jul 2019 07:21:02 -0600 Subject: [PATCH 1/6] feat: Give control over ignoring hidden files --- src/main.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 7688190..af2201d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,7 @@ impl Default for Format { } #[derive(Debug, StructOpt)] +#[structopt(rename_all = "kebab-case")] struct Options { #[structopt(parse(from_os_str), default_value = ".")] /// Paths to check @@ -47,6 +48,12 @@ struct Options { #[structopt(short = "j", long = "threads", default_value = "0")] /// The approximate number of threads to use. threads: usize, + + #[structopt(long, raw(overrides_with = r#""no-hidden""#))] + /// Search hidden files and directories. + hidden: bool, + #[structopt(long, raw(overrides_with = r#""hidden""#), raw(hidden = "true"))] + no_hidden: bool, } impl Options { @@ -57,6 +64,15 @@ impl Options { self } + + pub fn ignore_hidden(&self) -> Option { + match (self.hidden, self.no_hidden) { + (true, false) => Some(false), + (false, true) => Some(true), + (false, false) => None, + (_, _) => unreachable!("StructOpt should make this impossible"), + } + } } fn run() -> Result<(), failure::Error> { @@ -72,7 +88,8 @@ fn run() -> Result<(), failure::Error> { for path in &options.path[1..] { walk.add(path); } - walk.threads(options.threads); + walk.threads(options.threads) + .hidden(options.ignore_hidden().unwrap_or(true)); // TODO Add build_parallel for options.threads != 1 for entry in walk.build() { let entry = entry?; From e6d29070fc735667e600c16b52b31a4da7222f39 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 10 Jul 2019 20:12:14 -0600 Subject: [PATCH 2/6] feat: Expose control over .ignore --- src/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index af2201d..db668a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,12 @@ struct Options { hidden: bool, #[structopt(long, raw(overrides_with = r#""hidden""#), raw(hidden = "true"))] no_hidden: bool, + + #[structopt(long, raw(overrides_with = r#""ignore-dot""#))] + /// Don't respect .ignore files. + no_ignore_dot: bool, + #[structopt(long, raw(overrides_with = r#""no-ignore-dot""#), raw(hidden = "true"))] + ignore_dot: bool, } impl Options { @@ -73,6 +79,15 @@ impl Options { (_, _) => unreachable!("StructOpt should make this impossible"), } } + + pub fn ignore_dot(&self) -> Option { + match (self.no_ignore_dot, self.ignore_dot) { + (true, false) => Some(false), + (false, true) => Some(true), + (false, false) => None, + (_, _) => unreachable!("StructOpt should make this impossible"), + } + } } fn run() -> Result<(), failure::Error> { @@ -89,7 +104,8 @@ fn run() -> Result<(), failure::Error> { walk.add(path); } walk.threads(options.threads) - .hidden(options.ignore_hidden().unwrap_or(true)); + .hidden(options.ignore_hidden().unwrap_or(true)) + .ignore(options.ignore_dot().unwrap_or(true)); // TODO Add build_parallel for options.threads != 1 for entry in walk.build() { let entry = entry?; From 27edfc6e02213f1392096b13652ad4df4036a0c6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 11 Jul 2019 21:56:27 -0600 Subject: [PATCH 3/6] feat: Global ignore file flag --- src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main.rs b/src/main.rs index db668a4..2292153 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,6 +55,12 @@ struct Options { #[structopt(long, raw(overrides_with = r#""hidden""#), raw(hidden = "true"))] no_hidden: bool, + #[structopt(long, raw(overrides_with = r#""ignore""#))] + /// Don't respect ignore files. + no_ignore: bool, + #[structopt(long, raw(overrides_with = r#""no-ignore""#), raw(hidden = "true"))] + ignore: bool, + #[structopt(long, raw(overrides_with = r#""ignore-dot""#))] /// Don't respect .ignore files. no_ignore_dot: bool, @@ -87,6 +93,16 @@ impl Options { (false, false) => None, (_, _) => unreachable!("StructOpt should make this impossible"), } + .or_else(|| self.ignore_files()) + } + + fn ignore_files(&self) -> Option { + match (self.no_ignore, self.ignore) { + (true, false) => Some(false), + (false, true) => Some(true), + (false, false) => None, + (_, _) => unreachable!("StructOpt should make this impossible"), + } } } From 1bd4ca828877acb354cc923f7439a32a22af544e Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 12 Jul 2019 21:36:32 -0600 Subject: [PATCH 4/6] feat: Git global flag --- src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 2292153..3111eaf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,6 +66,16 @@ struct Options { no_ignore_dot: bool, #[structopt(long, raw(overrides_with = r#""no-ignore-dot""#), raw(hidden = "true"))] ignore_dot: bool, + + #[structopt(long, raw(overrides_with = r#""ignore-global""#))] + /// Don't respect global ignore files. + no_ignore_global: bool, + #[structopt( + long, + raw(overrides_with = r#""no-ignore-global""#), + raw(hidden = "true") + )] + ignore_global: bool, } impl Options { @@ -96,6 +106,16 @@ impl Options { .or_else(|| self.ignore_files()) } + pub fn ignore_global(&self) -> Option { + match (self.no_ignore_global, self.ignore_global) { + (true, false) => Some(false), + (false, true) => Some(true), + (false, false) => None, + (_, _) => unreachable!("StructOpt should make this impossible"), + } + .or_else(|| self.ignore_files()) + } + fn ignore_files(&self) -> Option { match (self.no_ignore, self.ignore) { (true, false) => Some(false), @@ -121,7 +141,8 @@ fn run() -> Result<(), failure::Error> { } walk.threads(options.threads) .hidden(options.ignore_hidden().unwrap_or(true)) - .ignore(options.ignore_dot().unwrap_or(true)); + .ignore(options.ignore_dot().unwrap_or(true)) + .git_global(options.ignore_global().unwrap_or(true)); // TODO Add build_parallel for options.threads != 1 for entry in walk.build() { let entry = entry?; From 6bbf8390ff1e4c9d41688c2746ab1070f9e25a4e Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 12 Jul 2019 21:39:38 -0600 Subject: [PATCH 5/6] feat: Ignore parents flag --- src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3111eaf..a784e4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,6 +76,16 @@ struct Options { raw(hidden = "true") )] ignore_global: bool, + + #[structopt(long, raw(overrides_with = r#""ignore-parent""#))] + /// Don't respect ignore files in parent directories. + no_ignore_parent: bool, + #[structopt( + long, + raw(overrides_with = r#""no-ignore-parent""#), + raw(hidden = "true") + )] + ignore_parent: bool, } impl Options { @@ -116,6 +126,16 @@ impl Options { .or_else(|| self.ignore_files()) } + pub fn ignore_parent(&self) -> Option { + match (self.no_ignore_parent, self.ignore_parent) { + (true, false) => Some(false), + (false, true) => Some(true), + (false, false) => None, + (_, _) => unreachable!("StructOpt should make this impossible"), + } + .or_else(|| self.ignore_files()) + } + fn ignore_files(&self) -> Option { match (self.no_ignore, self.ignore) { (true, false) => Some(false), @@ -142,7 +162,8 @@ fn run() -> Result<(), failure::Error> { walk.threads(options.threads) .hidden(options.ignore_hidden().unwrap_or(true)) .ignore(options.ignore_dot().unwrap_or(true)) - .git_global(options.ignore_global().unwrap_or(true)); + .git_global(options.ignore_global().unwrap_or(true)) + .parents(options.ignore_parent().unwrap_or(true)); // TODO Add build_parallel for options.threads != 1 for entry in walk.build() { let entry = entry?; From 73054cca9e49de71e4519688a1490d82aaf569f9 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 12 Jul 2019 21:43:18 -0600 Subject: [PATCH 6/6] feat: VCS ignore flag --- src/main.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.rs b/src/main.rs index a784e4f..ff8bce9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,6 +86,12 @@ struct Options { raw(hidden = "true") )] ignore_parent: bool, + + #[structopt(long, raw(overrides_with = r#""ignore-vcs""#))] + /// Don't respect ignore files in vcs directories. + no_ignore_vcs: bool, + #[structopt(long, raw(overrides_with = r#""no-ignore-vcs""#), raw(hidden = "true"))] + ignore_vcs: bool, } impl Options { @@ -123,6 +129,7 @@ impl Options { (false, false) => None, (_, _) => unreachable!("StructOpt should make this impossible"), } + .or_else(|| self.ignore_vcs()) .or_else(|| self.ignore_files()) } @@ -136,6 +143,16 @@ impl Options { .or_else(|| self.ignore_files()) } + pub fn ignore_vcs(&self) -> Option { + match (self.no_ignore_vcs, self.ignore_vcs) { + (true, false) => Some(false), + (false, true) => Some(true), + (false, false) => None, + (_, _) => unreachable!("StructOpt should make this impossible"), + } + .or_else(|| self.ignore_files()) + } + fn ignore_files(&self) -> Option { match (self.no_ignore, self.ignore) { (true, false) => Some(false), @@ -163,6 +180,8 @@ fn run() -> Result<(), failure::Error> { .hidden(options.ignore_hidden().unwrap_or(true)) .ignore(options.ignore_dot().unwrap_or(true)) .git_global(options.ignore_global().unwrap_or(true)) + .git_ignore(options.ignore_vcs().unwrap_or(true)) + .git_exclude(options.ignore_vcs().unwrap_or(true)) .parents(options.ignore_parent().unwrap_or(true)); // TODO Add build_parallel for options.threads != 1 for entry in walk.build() {