mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-27 07:38:27 +00:00
Fix --tree --all
Fixes #193. --all was treated the same as --all --all; now it’s treated differently.
This commit is contained in:
parent
0831573669
commit
a2cd39e0a9
@ -87,17 +87,11 @@ impl SortField {
|
||||
|
||||
impl DotFilter {
|
||||
pub fn deduce(matches: &Matches) -> Result<DotFilter, Misfire> {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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<OsString> = 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user