mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-26 22:06:26 +00:00
Forbid --tree --all --all
There’s a problem with the tree view where it’ll still recurse through `.` and `..`. But if you were using tree view, would you even need to see them? They’d be in the tree already!
This commit is contained in:
parent
dd8bff083f
commit
340bccbcfc
@ -78,7 +78,7 @@ impl FileFilter {
|
||||
list_dirs_first: matches.opt_present("group-directories-first"),
|
||||
reverse: matches.opt_present("reverse"),
|
||||
sort_field: SortField::deduce(matches)?,
|
||||
dot_filter: DotFilter::deduce(matches),
|
||||
dot_filter: DotFilter::deduce(matches)?,
|
||||
ignore_patterns: IgnorePatterns::deduce(matches)?,
|
||||
})
|
||||
}
|
||||
@ -251,11 +251,18 @@ impl SortField {
|
||||
|
||||
|
||||
impl DotFilter {
|
||||
pub fn deduce(matches: &getopts::Matches) -> DotFilter {
|
||||
match matches.opt_count("all") {
|
||||
0 => DotFilter::JustFiles,
|
||||
pub fn deduce(matches: &getopts::Matches) -> Result<DotFilter, Misfire> {
|
||||
let dots = match matches.opt_count("all") {
|
||||
0 => return Ok(DotFilter::JustFiles),
|
||||
1 => DotFilter::Dotfiles,
|
||||
_ => DotFilter::DotfilesAndDots,
|
||||
};
|
||||
|
||||
if matches.opt_present("tree") {
|
||||
Err(Misfire::Useless("all --all", true, "tree"))
|
||||
}
|
||||
else {
|
||||
Ok(dots)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +279,11 @@ mod test {
|
||||
assert_eq!(opts.unwrap_err(), Misfire::Useless2("level", "recurse", "tree"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_all_with_tree() {
|
||||
let opts = Options::getopts(&[ "--all", "--all", "--tree" ]);
|
||||
assert_eq!(opts.unwrap_err(), Misfire::Useless("all --all", true, "tree"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nowt() {
|
||||
|
Loading…
Reference in New Issue
Block a user