mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-26 13:56:27 +00:00
Thread the row threshold through grid_details
No new features here, just some restructuring. Mode::GridDetails was nice and elegant with those two fields, but now there’s a grid-details-only option the elegance has gone out the window.
This commit is contained in:
parent
a6ed42105d
commit
da00e2fda2
16
src/exa.rs
16
src/exa.rs
@ -181,10 +181,18 @@ impl<'args, 'w, W: Write + 'w> Exa<'args, 'w, W> {
|
||||
let View { ref mode, ref colours, ref style } = self.options.view;
|
||||
|
||||
match *mode {
|
||||
Mode::Lines => lines::Render { files, colours, style }.render(self.writer),
|
||||
Mode::Grid(ref opts) => grid::Render { files, colours, style, opts }.render(self.writer),
|
||||
Mode::Details(ref opts) => details::Render { dir, files, colours, style, opts, filter: &self.options.filter, recurse: self.options.dir_action.recurse_options() }.render(self.writer),
|
||||
Mode::GridDetails(ref grid, ref details) => grid_details::Render { dir, files, colours, style, grid, details, filter: &self.options.filter, row_threshold: Some(10) }.render(self.writer),
|
||||
Mode::Lines => {
|
||||
lines::Render { files, colours, style }.render(self.writer)
|
||||
}
|
||||
Mode::Grid(ref opts) => {
|
||||
grid::Render { files, colours, style, opts }.render(self.writer)
|
||||
}
|
||||
Mode::Details(ref opts) => {
|
||||
details::Render { dir, files, colours, style, opts, filter: &self.options.filter, recurse: self.options.dir_action.recurse_options() }.render(self.writer)
|
||||
}
|
||||
Mode::GridDetails(ref opts) => {
|
||||
grid_details::Render { dir, files, colours, style, grid: &opts.grid, details: &opts.details, filter: &self.options.filter, row_threshold: opts.row_threshold }.render(self.writer)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -73,8 +73,7 @@ use std::ffi::{OsStr, OsString};
|
||||
|
||||
use fs::dir_action::DirAction;
|
||||
use fs::filter::FileFilter;
|
||||
use output::{View, Mode};
|
||||
use output::details;
|
||||
use output::{View, Mode, details, grid_details};
|
||||
|
||||
mod dir_action;
|
||||
mod filter;
|
||||
@ -145,7 +144,7 @@ impl Options {
|
||||
pub fn should_scan_for_git(&self) -> bool {
|
||||
match self.view.mode {
|
||||
Mode::Details(details::Options { table: Some(ref table), .. }) |
|
||||
Mode::GridDetails(_, details::Options { table: Some(ref table), .. }) => table.extra_columns.should_scan_for_git(),
|
||||
Mode::GridDetails(grid_details::Options { details: details::Options { table: Some(ref table), .. }, .. }) => table.extra_columns.should_scan_for_git(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use output::Colours;
|
||||
use output::{View, Mode, grid, details};
|
||||
use output::{View, Mode, grid, details, grid_details};
|
||||
use output::table::{TimeTypes, Environment, SizeFormat, Columns, Options as TableOptions};
|
||||
use output::file_name::{Classify, FileStyle};
|
||||
use output::time::TimeFormat;
|
||||
@ -96,7 +96,7 @@ impl Mode {
|
||||
let details = long()?;
|
||||
if matches.has(&flags::GRID)? {
|
||||
match other_options_scan()? {
|
||||
Mode::Grid(grid) => return Ok(Mode::GridDetails(grid, details)),
|
||||
Mode::Grid(grid) => return Ok(Mode::GridDetails(grid_details::Options { grid, details, row_threshold: Some(5) })),
|
||||
others => return Ok(others),
|
||||
};
|
||||
}
|
||||
@ -643,8 +643,8 @@ mod test {
|
||||
test!(ell: Mode <- ["-l"], None; Both => like Ok(Mode::Details(_)));
|
||||
|
||||
// Grid-details views
|
||||
test!(lid: Mode <- ["--long", "--grid"], None; Both => like Ok(Mode::GridDetails(_, _)));
|
||||
test!(leg: Mode <- ["-lG"], None; Both => like Ok(Mode::GridDetails(_, _)));
|
||||
test!(lid: Mode <- ["--long", "--grid"], None; Both => like Ok(Mode::GridDetails(_)));
|
||||
test!(leg: Mode <- ["-lG"], None; Both => like Ok(Mode::GridDetails(_)));
|
||||
|
||||
|
||||
// Options that do nothing without --long
|
||||
|
@ -18,6 +18,14 @@ use output::table::{Table, Row as TableRow, Options as TableOptions};
|
||||
use output::tree::{TreeParams, TreeDepth};
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Options {
|
||||
pub grid: GridOptions,
|
||||
pub details: DetailsOptions,
|
||||
pub row_threshold: Option<usize>,
|
||||
}
|
||||
|
||||
|
||||
pub struct Render<'a> {
|
||||
|
||||
/// The directory that’s being rendered here.
|
||||
|
@ -33,6 +33,6 @@ pub struct View {
|
||||
pub enum Mode {
|
||||
Grid(grid::Options),
|
||||
Details(details::Options),
|
||||
GridDetails(grid::Options, details::Options),
|
||||
GridDetails(grid_details::Options),
|
||||
Lines,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user