mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-09-28 05:09:01 +00:00
Add support for suppressing table columns
This commit is contained in:
parent
89c861f24d
commit
925f5173c1
@ -60,6 +60,10 @@ These options are available when running with --long (`-l`):
|
|||||||
- **-@**, **--extended**: list each file's extended attributes and sizes
|
- **-@**, **--extended**: list each file's extended attributes and sizes
|
||||||
- **--git**: list each file's Git status, if tracked or ignored
|
- **--git**: list each file's Git status, if tracked or ignored
|
||||||
- **--time-style**: how to format timestamps
|
- **--time-style**: how to format timestamps
|
||||||
|
- **--no-permissions**: suppress the permissions field
|
||||||
|
- **--no-filesize**: suppress the filesize field
|
||||||
|
- **--no-user**: suppress the user field
|
||||||
|
- **--no-time**: suppress the time field
|
||||||
|
|
||||||
- Valid **--color** options are **always**, **automatic**, and **never**.
|
- Valid **--color** options are **always**, **automatic**, and **never**.
|
||||||
- Valid sort fields are **accessed**, **changed**, **created**, **extension**, **Extension**, **inode**, **modified**, **name**, **Name**, **size**, **type**, and **none**. Fields starting with a capital letter sort uppercase before lowercase. The modified field has the aliases **date**, **time**, and **newest**, while its reverse has the aliases **age** and **oldest**.
|
- Valid sort fields are **accessed**, **changed**, **created**, **extension**, **Extension**, **inode**, **modified**, **name**, **Name**, **size**, **type**, and **none**. Fields starting with a capital letter sort uppercase before lowercase. The modified field has the aliases **date**, **time**, and **newest**, while its reverse has the aliases **age** and **oldest**.
|
||||||
|
@ -53,6 +53,12 @@ pub static TIME_STYLE: Arg = Arg { short: None, long: "time-style", takes_
|
|||||||
const TIMES: Values = &["modified", "changed", "accessed", "created"];
|
const TIMES: Values = &["modified", "changed", "accessed", "created"];
|
||||||
const TIME_STYLES: Values = &["default", "long-iso", "full-iso", "iso"];
|
const TIME_STYLES: Values = &["default", "long-iso", "full-iso", "iso"];
|
||||||
|
|
||||||
|
// suppressing columns
|
||||||
|
pub static NO_PERMISSIONS: Arg = Arg { short: None, long: "no-permissions", takes_value: TakesValue::Forbidden };
|
||||||
|
pub static NO_FILESIZE: Arg = Arg { short: None, long: "no-filesize", takes_value: TakesValue::Forbidden };
|
||||||
|
pub static NO_USER: Arg = Arg { short: None, long: "no-user", takes_value: TakesValue::Forbidden };
|
||||||
|
pub static NO_TIME: Arg = Arg { short: None, long: "no-time", takes_value: TakesValue::Forbidden };
|
||||||
|
|
||||||
// optional feature options
|
// optional feature options
|
||||||
pub static GIT: Arg = Arg { short: None, long: "git", takes_value: TakesValue::Forbidden };
|
pub static GIT: Arg = Arg { short: None, long: "git", takes_value: TakesValue::Forbidden };
|
||||||
pub static EXTENDED: Arg = Arg { short: Some(b'@'), long: "extended", takes_value: TakesValue::Forbidden };
|
pub static EXTENDED: Arg = Arg { short: Some(b'@'), long: "extended", takes_value: TakesValue::Forbidden };
|
||||||
@ -69,6 +75,7 @@ pub static ALL_ARGS: Args = Args(&[
|
|||||||
|
|
||||||
&BINARY, &BYTES, &GROUP, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,
|
&BINARY, &BYTES, &GROUP, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,
|
||||||
&BLOCKS, &TIME, &ACCESSED, &CREATED, &TIME_STYLE,
|
&BLOCKS, &TIME, &ACCESSED, &CREATED, &TIME_STYLE,
|
||||||
|
&NO_PERMISSIONS, &NO_FILESIZE, &NO_USER, &NO_TIME,
|
||||||
|
|
||||||
&GIT, &EXTENDED,
|
&GIT, &EXTENDED,
|
||||||
]);
|
]);
|
||||||
|
@ -148,7 +148,7 @@ impl Options {
|
|||||||
pub fn should_scan_for_git(&self) -> bool {
|
pub fn should_scan_for_git(&self) -> bool {
|
||||||
match self.view.mode {
|
match self.view.mode {
|
||||||
Mode::Details(details::Options { table: Some(ref table), .. }) |
|
Mode::Details(details::Options { table: Some(ref table), .. }) |
|
||||||
Mode::GridDetails(grid_details::Options { details: details::Options { table: Some(ref table), .. }, .. }) => table.extra_columns.git,
|
Mode::GridDetails(grid_details::Options { details: details::Options { table: Some(ref table), .. }, .. }) => table.columns.git,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,8 +210,8 @@ impl TableOptions {
|
|||||||
let env = Environment::load_all();
|
let env = Environment::load_all();
|
||||||
let time_format = TimeFormat::deduce(matches, vars)?;
|
let time_format = TimeFormat::deduce(matches, vars)?;
|
||||||
let size_format = SizeFormat::deduce(matches)?;
|
let size_format = SizeFormat::deduce(matches)?;
|
||||||
let extra_columns = Columns::deduce(matches)?;
|
let columns = Columns::deduce(matches)?;
|
||||||
Ok(TableOptions { env, time_format, size_format, extra_columns })
|
Ok(TableOptions { env, time_format, size_format, columns })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,11 @@ impl Columns {
|
|||||||
let inode = matches.has(&flags::INODE)?;
|
let inode = matches.has(&flags::INODE)?;
|
||||||
let links = matches.has(&flags::LINKS)?;
|
let links = matches.has(&flags::LINKS)?;
|
||||||
|
|
||||||
Ok(Columns { time_types, git, blocks, group, inode, links })
|
let permissions = !matches.has(&flags::NO_PERMISSIONS)?;
|
||||||
|
let filesize = !matches.has(&flags::NO_FILESIZE)?;
|
||||||
|
let user = !matches.has(&flags::NO_USER)?;
|
||||||
|
|
||||||
|
Ok(Columns { time_types, git, blocks, group, inode, links, permissions, filesize, user })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +312,11 @@ impl TimeTypes {
|
|||||||
let accessed = matches.has(&flags::ACCESSED)?;
|
let accessed = matches.has(&flags::ACCESSED)?;
|
||||||
let created = matches.has(&flags::CREATED)?;
|
let created = matches.has(&flags::CREATED)?;
|
||||||
|
|
||||||
let time_types = if let Some(word) = possible_word {
|
let no_time = matches.has(&flags::NO_TIME)?;
|
||||||
|
|
||||||
|
let time_types = if no_time {
|
||||||
|
TimeTypes { modified: false, changed: false, accessed: false, created: false }
|
||||||
|
} else if let Some(word) = possible_word {
|
||||||
if modified {
|
if modified {
|
||||||
return Err(Misfire::Useless(&flags::MODIFIED, true, &flags::TIME));
|
return Err(Misfire::Useless(&flags::MODIFIED, true, &flags::TIME));
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@ pub struct Options {
|
|||||||
pub env: Environment,
|
pub env: Environment,
|
||||||
pub size_format: SizeFormat,
|
pub size_format: SizeFormat,
|
||||||
pub time_format: TimeFormat,
|
pub time_format: TimeFormat,
|
||||||
pub extra_columns: Columns,
|
pub columns: Columns,
|
||||||
}
|
}
|
||||||
|
|
||||||
// I had to make other types derive Debug,
|
// I had to make other types derive Debug,
|
||||||
// and Mutex<UsersCache> is not that!
|
// and Mutex<UsersCache> is not that!
|
||||||
impl fmt::Debug for Options {
|
impl fmt::Debug for Options {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
write!(f, "Table({:#?})", self.extra_columns)
|
write!(f, "Table({:#?})", self.columns)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +47,11 @@ pub struct Columns {
|
|||||||
pub blocks: bool,
|
pub blocks: bool,
|
||||||
pub group: bool,
|
pub group: bool,
|
||||||
pub git: bool,
|
pub git: bool,
|
||||||
|
|
||||||
|
// Defaults to true:
|
||||||
|
pub permissions: bool,
|
||||||
|
pub filesize: bool,
|
||||||
|
pub user: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Columns {
|
impl Columns {
|
||||||
@ -57,19 +62,25 @@ impl Columns {
|
|||||||
columns.push(Column::Inode);
|
columns.push(Column::Inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
columns.push(Column::Permissions);
|
if self.permissions {
|
||||||
|
columns.push(Column::Permissions);
|
||||||
|
}
|
||||||
|
|
||||||
if self.links {
|
if self.links {
|
||||||
columns.push(Column::HardLinks);
|
columns.push(Column::HardLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
columns.push(Column::FileSize);
|
if self.filesize {
|
||||||
|
columns.push(Column::FileSize);
|
||||||
|
}
|
||||||
|
|
||||||
if self.blocks {
|
if self.blocks {
|
||||||
columns.push(Column::Blocks);
|
columns.push(Column::Blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
columns.push(Column::User);
|
if self.user {
|
||||||
|
columns.push(Column::User);
|
||||||
|
}
|
||||||
|
|
||||||
if self.group {
|
if self.group {
|
||||||
columns.push(Column::Group);
|
columns.push(Column::Group);
|
||||||
@ -294,7 +305,7 @@ pub struct Row {
|
|||||||
|
|
||||||
impl<'a, 'f> Table<'a> {
|
impl<'a, 'f> Table<'a> {
|
||||||
pub fn new(options: &'a Options, git: Option<&'a GitCache>, colours: &'a Colours) -> Table<'a> {
|
pub fn new(options: &'a Options, git: Option<&'a GitCache>, colours: &'a Colours) -> Table<'a> {
|
||||||
let columns = options.extra_columns.collect(git.is_some());
|
let columns = options.columns.collect(git.is_some());
|
||||||
let widths = TableWidths::zero(columns.len());
|
let widths = TableWidths::zero(columns.len());
|
||||||
|
|
||||||
Table {
|
Table {
|
||||||
|
Loading…
Reference in New Issue
Block a user