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"), diff --git a/src/output/details.rs b/src/output/details.rs index 9988b69..f7c50b7 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -42,7 +42,7 @@ pub struct Details { /// A Columns object that says which columns should be included in the /// output in the general case. Directories themselves can pick which /// columns are *added* to this list, such as the Git column. - pub columns: Columns, + pub columns: Option, /// Whether to recurse through directories with a tree view, and if so, /// which options to use. This field is only relevant here if the `tree` @@ -64,7 +64,13 @@ impl Details { pub fn view(&self, dir: Option<&Dir>, files: &[File]) { // First, transform the Columns object into a vector of columns for // the current directory. - let mut table = Table::with_options(self.colours, self.columns.for_dir(dir)); + + let columns_for_dir = match self.columns { + Some(cols) => cols.for_dir(dir), + None => Vec::new(), + }; + + let mut table = Table::with_options(self.colours, columns_for_dir); if self.header { table.add_header() } // Then add files to the table and print it out. diff --git a/src/output/grid_details.rs b/src/output/grid_details.rs index 7886460..4daf85a 100644 --- a/src/output/grid_details.rs +++ b/src/output/grid_details.rs @@ -17,7 +17,11 @@ pub struct GridDetails { impl GridDetails { pub fn view(&self, dir: Option<&Dir>, files: &[File]) { - let columns_for_dir = self.details.columns.for_dir(dir); + let columns_for_dir = match self.details.columns { + Some(cols) => cols.for_dir(dir), + None => Vec::new(), + }; + let mut first_table = Table::with_options(self.details.colours, columns_for_dir.clone()); let cells: Vec<_> = files.iter().map(|file| first_table.cells_for_file(file)).collect();