diff --git a/src/app.rs b/src/app.rs index a1d44aa..8ba3f17 100644 --- a/src/app.rs +++ b/src/app.rs @@ -31,10 +31,10 @@ pub fn app() -> ArgMatches<'static> { .required(false), ) .arg( - Arg::with_name("search-hidden") - .help("Search hidden files and directories. By default, hidden files and directories are skipped.") + Arg::with_name("ignore-hidden") + .help("Ignore searching hidden files and directories. By default, hidden files and directories are included in the search results.") .short("H") - .long("search-hidden"), + .long("ignore-hidden"), ) .arg( Arg::with_name("case-sensitive") diff --git a/src/args.rs b/src/args.rs index 9675815..d41e931 100644 --- a/src/args.rs +++ b/src/args.rs @@ -10,7 +10,7 @@ use crate::app; pub struct Args { pub reg_exp: Regex, pub root_path: String, - pub search_hidden: bool, + pub ignore_hidden: bool, pub case_sensitive: bool, } @@ -33,8 +33,8 @@ impl ArgMatchesWrapper { self.matches.is_present("case-sensitive") } - fn should_search_hidden_files(&self) -> bool { - self.matches.is_present("search-hidden") + fn should_ignore_hidden_files(&self) -> bool { + self.matches.is_present("ignore-hidden") } fn search_pattern(&self) -> Regex { @@ -88,7 +88,7 @@ impl ArgMatchesWrapper { fn to_args(&self) -> Args { Args { root_path: self.root_path(), - search_hidden: self.should_search_hidden_files(), + ignore_hidden: self.should_ignore_hidden_files(), case_sensitive: self.is_case_sensitive(), reg_exp: self.search_pattern(), } diff --git a/src/walker.rs b/src/walker.rs index 5adcd17..d38ed62 100644 --- a/src/walker.rs +++ b/src/walker.rs @@ -19,20 +19,20 @@ impl<'a> Walker<'a> { } pub fn matching_paths(&self) -> Vec { - let paths = self + let paths: Vec = self .accessible_paths() .into_iter() .map(|p| self.truncate_working_dir_path(p.path().display().to_string())) .filter(|path| self.args.reg_exp.is_match(path)) .collect(); - if self.args.search_hidden { - paths - } else { + if self.args.ignore_hidden { paths .into_iter() .filter(|path| !path.contains("/.")) .collect() + } else { + paths } }