mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-11 16:34:26 +00:00
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).
This commit is contained in:
parent
ebbac61c74
commit
e1f4ea9215
@ -267,11 +267,11 @@ impl View {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let details = Details {
|
let details = Details {
|
||||||
columns: try!(Columns::deduce(matches)),
|
columns: Some(try!(Columns::deduce(matches))),
|
||||||
header: matches.opt_present("header"),
|
header: matches.opt_present("header"),
|
||||||
recurse: dir_action.recurse_options().map(|o| (o, filter)),
|
recurse: dir_action.recurse_options().map(|o| (o, filter)),
|
||||||
xattr: Attribute::feature_implemented() && matches.opt_present("extended"),
|
xattr: Attribute::feature_implemented() && matches.opt_present("extended"),
|
||||||
colours: if dimensions().is_some() { Colours::colourful() } else { Colours::plain() },
|
colours: if dimensions().is_some() { Colours::colourful() } else { Colours::plain() },
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(details)
|
Ok(details)
|
||||||
@ -279,7 +279,7 @@ impl View {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let long_options_scan = || {
|
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) {
|
if matches.opt_present(option) {
|
||||||
return Err(Useless(option, false, "long"));
|
return Err(Useless(option, false, "long"));
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ impl View {
|
|||||||
if cfg!(feature="git") && matches.opt_present("git") {
|
if cfg!(feature="git") && matches.opt_present("git") {
|
||||||
Err(Useless("git", false, "long"))
|
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"))
|
Err(Useless2("level", "recurse", "tree"))
|
||||||
}
|
}
|
||||||
else if Attribute::feature_implemented() && matches.opt_present("extended") {
|
else if Attribute::feature_implemented() && matches.opt_present("extended") {
|
||||||
@ -313,6 +313,17 @@ impl View {
|
|||||||
Ok(View::Lines(lines))
|
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 {
|
else {
|
||||||
let grid = Grid {
|
let grid = Grid {
|
||||||
across: matches.opt_present("across"),
|
across: matches.opt_present("across"),
|
||||||
|
@ -42,7 +42,7 @@ pub struct Details {
|
|||||||
/// A Columns object that says which columns should be included in the
|
/// A Columns object that says which columns should be included in the
|
||||||
/// output in the general case. Directories themselves can pick which
|
/// output in the general case. Directories themselves can pick which
|
||||||
/// columns are *added* to this list, such as the Git column.
|
/// 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,
|
/// 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`
|
/// 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]) {
|
pub fn view(&self, dir: Option<&Dir>, files: &[File]) {
|
||||||
// First, transform the Columns object into a vector of columns for
|
// First, transform the Columns object into a vector of columns for
|
||||||
// the current directory.
|
// 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() }
|
if self.header { table.add_header() }
|
||||||
|
|
||||||
// Then add files to the table and print it out.
|
// Then add files to the table and print it out.
|
||||||
|
@ -17,7 +17,11 @@ pub struct GridDetails {
|
|||||||
|
|
||||||
impl GridDetails {
|
impl GridDetails {
|
||||||
pub fn view(&self, dir: Option<&Dir>, files: &[File]) {
|
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 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();
|
let cells: Vec<_> = files.iter().map(|file| first_table.cells_for_file(file)).collect();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user