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/output | |
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/output')
-rw-r--r-- | src/output/details.rs | 10 | ||||
-rw-r--r-- | src/output/grid_details.rs | 6 |
2 files changed, 13 insertions, 3 deletions
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<Columns>, /// 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(); |