mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-25 17:51:10 +00:00
Merge pull request #577 from 0rvar/feature/suppress-columns
Add support for suppressing table columns
This commit is contained in:
commit
1f167dda41
@ -60,6 +60,10 @@ These options are available when running with --long (`-l`):
|
||||
- **-@**, **--extended**: list each file's extended attributes and sizes
|
||||
- **--git**: list each file's Git status, if tracked or ignored
|
||||
- **--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 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**.
|
||||
|
@ -73,6 +73,10 @@ complete -c exa -l 'time-style' -x -d "How to format timestamps" -a "
|
||||
long-iso\t'Display longer ISO timestaps, up to the minute'
|
||||
full-iso\t'Display full ISO timestamps, up to the nanosecond'
|
||||
"
|
||||
complete -c exa -l 'no-permissions' -d "Suppress the permissions field"
|
||||
complete -c exa -l 'no-filesize' -d "Suppress the filesize field"
|
||||
complete -c exa -l 'no-user' -d "Suppress the user field"
|
||||
complete -c exa -l 'no-time' -d "Suppress the time field"
|
||||
|
||||
# Optional extras
|
||||
complete -c exa -s 'g' -l 'git' -d "List each file's Git status, if tracked"
|
||||
|
@ -40,6 +40,10 @@ __exa() {
|
||||
{-S,--blocks}"[List each file's number of filesystem blocks]" \
|
||||
{-t,--time}="[Which time field to show]:(time field):(accessed changed created modified)" \
|
||||
--time-style="[How to format timestamps]:(time style):(default iso long-iso full-iso)" \
|
||||
--no-permissions"[Suppress the permissions field]" \
|
||||
--no-filesize"[Suppress the filesize field]" \
|
||||
--no-user"[Suppress the user field]" \
|
||||
--no-time"[Suppress the time field]" \
|
||||
{-u,--accessed}"[Use the accessed timestamp field]" \
|
||||
{-U,--created}"[Use the created timestamp field]" \
|
||||
--git"[List each file's Git status, if tracked]" \
|
||||
|
@ -182,6 +182,26 @@ use the created timestamp field
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-no\-permissions
|
||||
suppress the permissions field
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-no\-filesize
|
||||
suppress the filesize field
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-no\-user
|
||||
suppress the user field
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \-\-no\-time
|
||||
suppress the time field
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \-\@, \-\-extended
|
||||
list each file\[aq]s extended attributes and sizes
|
||||
.RS
|
||||
|
@ -53,6 +53,12 @@ pub static TIME_STYLE: Arg = Arg { short: None, long: "time-style", takes_
|
||||
const TIMES: Values = &["modified", "changed", "accessed", "created"];
|
||||
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
|
||||
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 };
|
||||
@ -69,6 +75,7 @@ pub static ALL_ARGS: Args = Args(&[
|
||||
|
||||
&BINARY, &BYTES, &GROUP, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,
|
||||
&BLOCKS, &TIME, &ACCESSED, &CREATED, &TIME_STYLE,
|
||||
&NO_PERMISSIONS, &NO_FILESIZE, &NO_USER, &NO_TIME,
|
||||
|
||||
&GIT, &EXTENDED,
|
||||
]);
|
||||
|
@ -49,7 +49,11 @@ LONG VIEW OPTIONS
|
||||
-t, --time FIELD which timestamp field to list (modified, accessed, created)
|
||||
-u, --accessed use the accessed timestamp field
|
||||
-U, --created use the created timestamp field
|
||||
--time-style how to format timestamps (default, iso, long-iso, full-iso)"##;
|
||||
--time-style how to format timestamps (default, iso, long-iso, full-iso)
|
||||
--no-permissions suppress the permissions field
|
||||
--no-filesize suppress the filesize field
|
||||
--no-user suppress the user field
|
||||
--no-time suppress the time field"##;
|
||||
|
||||
static GIT_HELP: &str = r##" --git list each file's Git status, if tracked or ignored"##;
|
||||
static EXTENDED_HELP: &str = r##" -@, --extended list each file's extended attributes and sizes"##;
|
||||
|
@ -148,7 +148,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(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,
|
||||
}
|
||||
}
|
||||
|
@ -211,8 +211,8 @@ impl TableOptions {
|
||||
let env = Environment::load_all();
|
||||
let time_format = TimeFormat::deduce(matches, vars)?;
|
||||
let size_format = SizeFormat::deduce(matches)?;
|
||||
let extra_columns = Columns::deduce(matches)?;
|
||||
Ok(TableOptions { env, time_format, size_format, extra_columns })
|
||||
let columns = Columns::deduce(matches)?;
|
||||
Ok(TableOptions { env, time_format, size_format, columns })
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,7 +227,11 @@ impl Columns {
|
||||
let inode = matches.has(&flags::INODE)?;
|
||||
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 })
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,7 +313,11 @@ impl TimeTypes {
|
||||
let accessed = matches.has(&flags::ACCESSED)?;
|
||||
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 {
|
||||
return Err(Misfire::Useless(&flags::MODIFIED, true, &flags::TIME));
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ pub struct Options {
|
||||
pub env: Environment,
|
||||
pub size_format: SizeFormat,
|
||||
pub time_format: TimeFormat,
|
||||
pub extra_columns: Columns,
|
||||
pub columns: Columns,
|
||||
}
|
||||
|
||||
// I had to make other types derive Debug,
|
||||
// and Mutex<UsersCache> is not that!
|
||||
impl fmt::Debug for Options {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
write!(f, "Table({:#?})", self.extra_columns)
|
||||
write!(f, "Table({:#?})", self.columns)
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,6 +49,11 @@ pub struct Columns {
|
||||
pub blocks: bool,
|
||||
pub group: bool,
|
||||
pub git: bool,
|
||||
|
||||
// Defaults to true:
|
||||
pub permissions: bool,
|
||||
pub filesize: bool,
|
||||
pub user: bool,
|
||||
}
|
||||
|
||||
impl Columns {
|
||||
@ -59,19 +64,25 @@ impl Columns {
|
||||
columns.push(Column::Inode);
|
||||
}
|
||||
|
||||
columns.push(Column::Permissions);
|
||||
if self.permissions {
|
||||
columns.push(Column::Permissions);
|
||||
}
|
||||
|
||||
if self.links {
|
||||
columns.push(Column::HardLinks);
|
||||
}
|
||||
|
||||
columns.push(Column::FileSize);
|
||||
if self.filesize {
|
||||
columns.push(Column::FileSize);
|
||||
}
|
||||
|
||||
if self.blocks {
|
||||
columns.push(Column::Blocks);
|
||||
}
|
||||
|
||||
columns.push(Column::User);
|
||||
if self.user {
|
||||
columns.push(Column::User);
|
||||
}
|
||||
|
||||
if self.group {
|
||||
columns.push(Column::Group);
|
||||
@ -296,7 +307,7 @@ pub struct Row {
|
||||
|
||||
impl<'a, 'f> 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());
|
||||
|
||||
Table {
|
||||
|
@ -43,5 +43,9 @@ LONG VIEW OPTIONS
|
||||
-u, --accessed use the accessed timestamp field
|
||||
-U, --created use the created timestamp field
|
||||
--time-style how to format timestamps (default, iso, long-iso, full-iso)
|
||||
--no-permissions suppress the permissions field
|
||||
--no-filesize suppress the filesize field
|
||||
--no-user suppress the user field
|
||||
--no-time suppress the time field
|
||||
--git list each file's Git status, if tracked or ignored
|
||||
-@, --extended list each file's extended attributes and sizes
|
||||
|
Loading…
Reference in New Issue
Block a user