Mandate --recurse with --tree

Fixes #7.
This commit is contained in:
Ben S 2015-02-21 23:43:40 +00:00
parent 363d52dbb0
commit f8768e7c01

View File

@ -371,6 +371,7 @@ 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, false, false) => Ok(DirAction::Recurse),
(true, false, true ) => Ok(DirAction::Tree),
@ -543,4 +544,11 @@ mod test {
let opts = Options::getopts(&[ "--blocks".to_string() ]);
assert_eq!(opts.unwrap_err(), Misfire::Useless("blocks", false, "long"))
}
#[test]
fn tree_without_recurse() {
let opts = Options::getopts(&[ "--tree".to_string() ]);
assert_eq!(opts.unwrap_err(), Misfire::Useless("tree", false, "recurse"))
}
}