Skip to content

Commit a2cd39e

Browse files
committed
Fix --tree --all
Fixes #193. --all was treated the same as --all --all; now it’s treated differently.
1 parent 0831573 commit a2cd39e

File tree

2 files changed

+7
-41
lines changed

2 files changed

+7
-41
lines changed

src/options/filter.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,11 @@ impl SortField {
8787

8888
impl DotFilter {
8989
pub fn deduce(matches: &Matches) -> Result<DotFilter, Misfire> {
90-
let dots = match matches.count(&flags::ALL) {
91-
0 => return Ok(DotFilter::JustFiles),
92-
1 => DotFilter::Dotfiles,
93-
_ => DotFilter::DotfilesAndDots,
94-
};
95-
96-
if matches.has(&flags::TREE) {
97-
Err(Misfire::TreeAllAll)
98-
}
99-
else {
100-
Ok(dots)
90+
match matches.count(&flags::ALL) {
91+
0 => Ok(DotFilter::JustFiles),
92+
1 => Ok(DotFilter::Dotfiles),
93+
_ => if matches.has(&flags::TREE) { Err(Misfire::TreeAllAll) }
94+
else { Ok(DotFilter::DotfilesAndDots) }
10195
}
10296
}
10397
}
@@ -184,6 +178,7 @@ mod test {
184178
test!(all_all_2: DotFilter <- ["-aa"] => Ok(DotFilter::DotfilesAndDots));
185179

186180
// --all and --tree
187-
test!(tree: DotFilter <- ["-Taa"] => Err(Misfire::TreeAllAll));
181+
test!(tree_a: DotFilter <- ["-Ta"] => Ok(DotFilter::Dotfiles));
182+
test!(tree_aa: DotFilter <- ["-Taa"] => Err(Misfire::TreeAllAll));
188183
}
189184
}

src/options/mod.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ impl Options {
171171
mod test {
172172
use super::{Options, Misfire, flags};
173173
use std::ffi::OsString;
174-
use fs::DotFilter;
175174
use fs::filter::{SortField, SortCase};
176175
use fs::feature::xattr;
177176

@@ -333,32 +332,4 @@ mod test {
333332
let opts = Options::getopts(&args);
334333
assert_eq!(opts.unwrap_err(), Misfire::Useless2(&flags::LEVEL, &flags::RECURSE, &flags::TREE))
335334
}
336-
337-
#[test]
338-
fn all_all_with_tree() {
339-
let args = [ os("--all"), os("--all"), os("--tree") ];
340-
let opts = Options::getopts(&args);
341-
assert_eq!(opts.unwrap_err(), Misfire::TreeAllAll)
342-
}
343-
344-
#[test]
345-
fn nowt() {
346-
let nothing: Vec<OsString> = Vec::new();
347-
let dots = Options::getopts(&nothing).unwrap().0.filter.dot_filter;
348-
assert_eq!(dots, DotFilter::JustFiles);
349-
}
350-
351-
#[test]
352-
fn all() {
353-
let args = [ os("--all") ];
354-
let dots = Options::getopts(&args).unwrap().0.filter.dot_filter;
355-
assert_eq!(dots, DotFilter::Dotfiles);
356-
}
357-
358-
#[test]
359-
fn allall() {
360-
let args = [ os("-a"), os("-a") ];
361-
let dots = Options::getopts(&args).unwrap().0.filter.dot_filter;
362-
assert_eq!(dots, DotFilter::DotfilesAndDots);
363-
}
364335
}

0 commit comments

Comments
 (0)