From 867c53043b1be8af6a5c1f3fed10cd45796d4a0a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 10 Jul 2019 07:21:02 -0600 Subject: [PATCH] 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?;