diff --git a/src/options/filter.rs b/src/options/filter.rs index 3f80de2..58922f4 100644 --- a/src/options/filter.rs +++ b/src/options/filter.rs @@ -87,17 +87,11 @@ impl SortField { impl DotFilter { pub fn deduce(matches: &Matches) -> Result { - let dots = match matches.count(&flags::ALL) { - 0 => return Ok(DotFilter::JustFiles), - 1 => DotFilter::Dotfiles, - _ => DotFilter::DotfilesAndDots, - }; - - if matches.has(&flags::TREE) { - Err(Misfire::TreeAllAll) - } - else { - Ok(dots) + match matches.count(&flags::ALL) { + 0 => Ok(DotFilter::JustFiles), + 1 => Ok(DotFilter::Dotfiles), + _ => if matches.has(&flags::TREE) { Err(Misfire::TreeAllAll) } + else { Ok(DotFilter::DotfilesAndDots) } } } } @@ -184,6 +178,7 @@ mod test { test!(all_all_2: DotFilter <- ["-aa"] => Ok(DotFilter::DotfilesAndDots)); // --all and --tree - test!(tree: DotFilter <- ["-Taa"] => Err(Misfire::TreeAllAll)); + test!(tree_a: DotFilter <- ["-Ta"] => Ok(DotFilter::Dotfiles)); + test!(tree_aa: DotFilter <- ["-Taa"] => Err(Misfire::TreeAllAll)); } } diff --git a/src/options/mod.rs b/src/options/mod.rs index b45e910..1e4d2fb 100644 --- a/src/options/mod.rs +++ b/src/options/mod.rs @@ -171,7 +171,6 @@ impl Options { mod test { use super::{Options, Misfire, flags}; use std::ffi::OsString; - use fs::DotFilter; use fs::filter::{SortField, SortCase}; use fs::feature::xattr; @@ -333,32 +332,4 @@ mod test { let opts = Options::getopts(&args); assert_eq!(opts.unwrap_err(), Misfire::Useless2(&flags::LEVEL, &flags::RECURSE, &flags::TREE)) } - - #[test] - fn all_all_with_tree() { - let args = [ os("--all"), os("--all"), os("--tree") ]; - let opts = Options::getopts(&args); - assert_eq!(opts.unwrap_err(), Misfire::TreeAllAll) - } - - #[test] - fn nowt() { - let nothing: Vec = Vec::new(); - let dots = Options::getopts(¬hing).unwrap().0.filter.dot_filter; - assert_eq!(dots, DotFilter::JustFiles); - } - - #[test] - fn all() { - let args = [ os("--all") ]; - let dots = Options::getopts(&args).unwrap().0.filter.dot_filter; - assert_eq!(dots, DotFilter::Dotfiles); - } - - #[test] - fn allall() { - let args = [ os("-a"), os("-a") ]; - let dots = Options::getopts(&args).unwrap().0.filter.dot_filter; - assert_eq!(dots, DotFilter::DotfilesAndDots); - } }