Skip to content

Commit

Permalink
feat: Give control over ignoring hidden files
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 11, 2019
1 parent 166e263 commit 867c530
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -57,6 +64,15 @@ impl Options {

self
}

pub fn ignore_hidden(&self) -> Option<bool> {
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> {
Expand All @@ -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?;
Expand Down

0 comments on commit 867c530

Please sign in to comment.