diff options
author | Ben S <ogham@bsago.me> | 2015-08-03 13:54:25 +0100 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-08-03 13:54:25 +0100 |
commit | e1f4ea92151901d97bfe042564342bc62ef442e5 (patch) | |
tree | 8e2f6454103b5108841637960e42f15ac4a8045d /src/options.rs | |
parent | ebbac61c742aad0eb4e36ed25c7f7a2300106791 (diff) |
Allow --tree without --long
This kind of abuses the details view by giving it no columns when the Columns value is None (it's now Optional).
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/options.rs b/src/options.rs index 91c7f0f..08e3e9b 100644 --- a/src/options.rs +++ b/src/options.rs @@ -267,11 +267,11 @@ impl View { } else { let details = Details { - columns: try!(Columns::deduce(matches)), - header: matches.opt_present("header"), - recurse: dir_action.recurse_options().map(|o| (o, filter)), - xattr: Attribute::feature_implemented() && matches.opt_present("extended"), - colours: if dimensions().is_some() { Colours::colourful() } else { Colours::plain() }, + columns: Some(try!(Columns::deduce(matches))), + header: matches.opt_present("header"), + recurse: dir_action.recurse_options().map(|o| (o, filter)), + xattr: Attribute::feature_implemented() && matches.opt_present("extended"), + colours: if dimensions().is_some() { Colours::colourful() } else { Colours::plain() }, }; Ok(details) @@ -279,7 +279,7 @@ impl View { }; let long_options_scan = || { - for option in &[ "binary", "bytes", "inode", "links", "header", "blocks", "time", "tree", "group" ] { + for option in &[ "binary", "bytes", "inode", "links", "header", "blocks", "time", "group" ] { if matches.opt_present(option) { return Err(Useless(option, false, "long")); } @@ -288,7 +288,7 @@ impl View { if cfg!(feature="git") && matches.opt_present("git") { Err(Useless("git", false, "long")) } - else if matches.opt_present("level") && !matches.opt_present("recurse") { + else if matches.opt_present("level") && !matches.opt_present("recurse") && !matches.opt_present("tree") { Err(Useless2("level", "recurse", "tree")) } else if Attribute::feature_implemented() && matches.opt_present("extended") { @@ -313,6 +313,17 @@ impl View { Ok(View::Lines(lines)) } } + else if matches.opt_present("tree") { + let details = Details { + columns: None, + header: false, + recurse: dir_action.recurse_options().map(|o| (o, filter)), + xattr: false, + colours: if dimensions().is_some() { Colours::colourful() } else { Colours::plain() }, + }; + + Ok(View::Details(details)) + } else { let grid = Grid { across: matches.opt_present("across"), |