Allow --tree without --recurse

See #24
This commit is contained in:
Ben S 2015-02-23 16:08:51 +00:00
parent ce23c63d75
commit ea1b3caefa

View File

@ -47,7 +47,7 @@ impl Options {
if xattr::feature_implemented() {
opts.optflag("@", "extended",
"display extended attribute keys and sizes in long (-l) output"
);
);
}
opts.optflag("1", "oneline", "display one entry per line");
opts.optflag("a", "all", "show dot-files");
@ -220,7 +220,7 @@ impl View {
let details = Details {
columns: try!(Columns::deduce(matches)),
header: matches.opt_present("header"),
tree: matches.opt_present("recurse"),
tree: matches.opt_present("recurse") || matches.opt_present("tree"),
xattr: xattr::feature_implemented() && matches.opt_present("extended"),
filter: filter,
};
@ -383,10 +383,10 @@ impl DirAction {
let tree = matches.opt_present("tree");
match (recurse, list, tree) {
(false, _, true ) => Err(Misfire::Useless("tree", false, "recurse")),
(true, true, _ ) => Err(Misfire::Conflict("recurse", "list-dirs")),
(_, true, true ) => Err(Misfire::Conflict("tree", "list-dirs")),
(true, false, false) => Ok(DirAction::Recurse),
(true, false, true ) => Ok(DirAction::Tree),
(_ , _, true ) => Ok(DirAction::Tree),
(false, true, _ ) => Ok(DirAction::AsFile),
(false, false, _ ) => Ok(DirAction::List),
}
@ -565,11 +565,4 @@ mod test {
assert_eq!(opts.unwrap_err(), Misfire::Useless("extended", false, "long"))
}
}
#[test]
fn tree_without_recurse() {
let opts = Options::getopts(&[ "--tree".to_string() ]);
assert_eq!(opts.unwrap_err(), Misfire::Useless("tree", false, "recurse"))
}
}