Преглед изворни кода

fix(ci): fmt, windows, and nix fixes

xempt пре 2 година
родитељ
комит
8b243a554f
10 измењених фајлова са 459 додато и 114 уклоњено
  1. 20 12
      src/fs/file.rs
  2. 57 10
      src/fs/filter.rs
  3. 2 2
      src/fs/mod.rs
  4. 3 3
      src/main.rs
  5. 362 75
      src/options/flags.rs
  6. 1 1
      src/options/view.rs
  7. 1 1
      src/output/details.rs
  8. 4 2
      src/output/grid_details.rs
  9. 1 1
      src/output/mod.rs
  10. 8 7
      src/output/table.rs

+ 20 - 12
src/fs/file.rs

@@ -15,7 +15,6 @@ use log::*;
 use crate::fs::dir::Dir;
 use crate::fs::feature::xattr;
 use crate::fs::feature::xattr::{Attribute, FileAttributes};
-use crate::fs::RECURSIVE_SIZE_HASHMAP;
 use crate::fs::fields as f;
 
 use super::mounts::all_mounts;
@@ -518,28 +517,29 @@ impl<'dir> File<'dir> {
     /// Recursive folder size
     #[cfg(unix)]
     pub fn recursive_size(&self) -> f::Size {
+        use crate::fs::RECURSIVE_SIZE_HASHMAP;
         if self.is_directory() {
-            let dir = match Dir::read_dir(self.path.clone()) {
-                Ok(v) => v,
-                Err(_) => return f::Size::None
+            let Ok(dir) = Dir::read_dir(self.path.clone()) else {
+                return f::Size::None;
             };
-            let mut recursive_size: u64 = 0;
             let files = dir.files(super::DotFilter::Dotfiles, None, false, false);
+
+            let mut recursive_size: u64 = 0;
             for fileresult in files {
-                let file = match fileresult {
-                    Ok(f) => f,
-                    _ => continue
-                };
+                let Ok(file) = fileresult else { continue };
                 if file.is_file() {
                     recursive_size += file.metadata.size();
                 } else {
                     recursive_size += match file.recursive_size() {
                         f::Size::Some(s) => s,
-                        _ => file.metadata.size()
+                        _ => file.metadata.size(),
                     };
                 }
             }
-            RECURSIVE_SIZE_HASHMAP.lock().unwrap().insert(self.metadata.ino(), recursive_size);
+            RECURSIVE_SIZE_HASHMAP
+                .lock()
+                .unwrap()
+                .insert(self.metadata.ino(), recursive_size);
             f::Size::Some(recursive_size)
         } else if self.is_char_device() || self.is_block_device() {
             let device_id = self.metadata.rdev();
@@ -566,7 +566,6 @@ impl<'dir> File<'dir> {
         }
     }
 
-
     /// Returns the size of the file or indicates no size if it's a directory.
     ///
     /// For Windows platforms, the size of directories is not computed and will
@@ -580,6 +579,15 @@ impl<'dir> File<'dir> {
         }
     }
 
+    #[cfg(windows)]
+    pub fn recursive_size(&self) -> f::Size {
+        if self.is_directory() {
+            f::Size::None
+        } else {
+            f::Size::Some(self.metadata.len())
+        }
+    }
+
     /// Determines if the directory is empty or not.
     ///
     /// For Unix platforms, this function first checks the link count to quickly

+ 57 - 10
src/fs/filter.rs

@@ -230,6 +230,7 @@ impl SortField {
     /// into groups between letters and numbers, and then sorts those blocks
     /// together, so `file10` will sort after `file9`, instead of before it
     /// because of the `1`.
+    #[cfg(unix)]
     pub fn compare_files(self, a: &File<'_>, b: &File<'_>) -> Ordering {
         use self::SortCase::{ABCabc, AaBbCc};
         use crate::fs::RECURSIVE_SIZE_HASHMAP;
@@ -242,16 +243,16 @@ impl SortField {
             Self::Name(AaBbCc)  => natord::compare_ignore_case(&a.name, &b.name),
 
             Self::Size => {
-                let mut _map = RECURSIVE_SIZE_HASHMAP.lock().unwrap();
-                let asize: u64 = match _map.get(&a.metadata.ino()) {
+                let recursive_map = RECURSIVE_SIZE_HASHMAP.lock().unwrap();
+                match recursive_map.get(&a.metadata.ino()) {
                     Some(s) => *s,
                     _ => a.metadata.len()
-                };
-                let bsize = match _map.get(&b.metadata.ino()) {
-                    Some(s) => *s,
-                    _ => b.metadata.len()
-                };
-                asize.cmp(&bsize)
+                }.cmp(
+                    &match recursive_map.get(&b.metadata.ino()) {
+                        Some(s) => *s,
+                        _ => b.metadata.len()
+                    }
+                )
             }
 
             #[cfg(unix)]
@@ -261,7 +262,6 @@ impl SortField {
             Self::ChangedDate   => a.changed_time().cmp(&b.changed_time()),
             Self::CreatedDate   => a.created_time().cmp(&b.created_time()),
             Self::ModifiedAge   => b.modified_time().cmp(&a.modified_time()),  // flip b and a
-
             Self::FileType => match a.type_char().cmp(&b.type_char()) { // todo: this recomputes
                 Ordering::Equal  => natord::compare(&a.name, &b.name),
                 order            => order,
@@ -284,7 +284,7 @@ impl SortField {
             Self::NameMixHidden(AaBbCc) => natord::compare_ignore_case(
                 Self::strip_dot(&a.name),
                 Self::strip_dot(&b.name)
-            )
+            ),
         };
     }
 
@@ -294,6 +294,53 @@ impl SortField {
             None => n,
         }
     }
+
+    /// Windows safe version of the above
+    #[cfg(windows)]
+    pub fn compare_files(self, a: &File<'_>, b: &File<'_>) -> Ordering {
+        use self::SortCase::{ABCabc, AaBbCc};
+
+        #[rustfmt::skip]
+        return match self {
+            Self::Unsorted  => Ordering::Equal,
+
+            Self::Name(ABCabc)  => natord::compare(&a.name, &b.name),
+            Self::Name(AaBbCc)  => natord::compare_ignore_case(&a.name, &b.name),
+
+            Self::Size => a.metadata.len().cmp(&b.metadata.len()),
+
+            #[cfg(unix)]
+            Self::FileInode     => a.metadata.ino().cmp(&b.metadata.ino()),
+            Self::ModifiedDate  => a.modified_time().cmp(&b.modified_time()),
+            Self::AccessedDate  => a.accessed_time().cmp(&b.accessed_time()),
+            Self::ChangedDate   => a.changed_time().cmp(&b.changed_time()),
+            Self::CreatedDate   => a.created_time().cmp(&b.created_time()),
+            Self::ModifiedAge   => b.modified_time().cmp(&a.modified_time()),  // flip b and a
+            Self::FileType => match a.type_char().cmp(&b.type_char()) { // todo: this recomputes
+                Ordering::Equal  => natord::compare(&a.name, &b.name),
+                order            => order,
+            },
+
+            Self::Extension(ABCabc) => match a.ext.cmp(&b.ext) {
+                Ordering::Equal  => natord::compare(&a.name, &b.name),
+                order            => order,
+            },
+
+            Self::Extension(AaBbCc) => match a.ext.cmp(&b.ext) {
+                Ordering::Equal  => natord::compare_ignore_case(&a.name, &b.name),
+                order            => order,
+            },
+
+            Self::NameMixHidden(ABCabc) => natord::compare(
+                Self::strip_dot(&a.name),
+                Self::strip_dot(&b.name)
+            ),
+            Self::NameMixHidden(AaBbCc) => natord::compare_ignore_case(
+                Self::strip_dot(&a.name),
+                Self::strip_dot(&b.name)
+            ),
+        };
+    }
 }
 
 /// The **ignore patterns** are a list of globs that are tested against

+ 2 - 2
src/fs/mod.rs

@@ -10,9 +10,9 @@ pub mod fields;
 pub mod filter;
 pub mod mounts;
 
-use std::sync::Mutex;
-use std::collections::HashMap;
 use lazy_static::lazy_static;
+use std::collections::HashMap;
+use std::sync::Mutex;
 lazy_static! {
     static ref RECURSIVE_SIZE_HASHMAP: Mutex<HashMap<u64, u64>> = Mutex::new(HashMap::new());
 }

+ 3 - 3
src/main.rs

@@ -365,7 +365,7 @@ impl<'args> Exa<'args> {
                     filter,
                     git_ignoring,
                     git,
-                    total_size
+                    total_size,
                 };
                 r.render(&mut self.writer)
             }
@@ -392,7 +392,7 @@ impl<'args> Exa<'args> {
                     git_ignoring,
                     git,
                     console_width,
-                    total_size
+                    total_size,
                 };
                 r.render(&mut self.writer)
             }
@@ -415,7 +415,7 @@ impl<'args> Exa<'args> {
                     filter,
                     git_ignoring,
                     git,
-                    total_size
+                    total_size,
                 };
                 r.render(&mut self.writer)
             }

+ 362 - 75
src/options/flags.rs

@@ -1,96 +1,383 @@
 use crate::options::parser::{Arg, Args, TakesValue, Values};
 
 // exa options
-pub static VERSION: Arg = Arg { short: Some(b'v'), long: "version",  takes_value: TakesValue::Forbidden };
-pub static HELP:    Arg = Arg { short: Some(b'?'), long: "help",     takes_value: TakesValue::Forbidden };
+pub static VERSION: Arg = Arg {
+    short: Some(b'v'),
+    long: "version",
+    takes_value: TakesValue::Forbidden,
+};
+pub static HELP: Arg = Arg {
+    short: Some(b'?'),
+    long: "help",
+    takes_value: TakesValue::Forbidden,
+};
 
 // display options
-pub static ONE_LINE:    Arg = Arg { short: Some(b'1'), long: "oneline",     takes_value: TakesValue::Forbidden };
-pub static LONG:        Arg = Arg { short: Some(b'l'), long: "long",        takes_value: TakesValue::Forbidden };
-pub static GRID:        Arg = Arg { short: Some(b'G'), long: "grid",        takes_value: TakesValue::Forbidden };
-pub static ACROSS:      Arg = Arg { short: Some(b'x'), long: "across",      takes_value: TakesValue::Forbidden };
-pub static RECURSE:     Arg = Arg { short: Some(b'R'), long: "recurse",     takes_value: TakesValue::Forbidden };
-pub static TREE:        Arg = Arg { short: Some(b'T'), long: "tree",        takes_value: TakesValue::Forbidden };
-pub static CLASSIFY:    Arg = Arg { short: Some(b'F'), long: "classify",    takes_value: TakesValue::Forbidden };
-pub static DEREF_LINKS: Arg = Arg { short: Some(b'X'), long: "dereference", takes_value: TakesValue::Forbidden };
-pub static WIDTH:       Arg = Arg { short: Some(b'w'), long: "width",       takes_value: TakesValue::Necessary(None) };
-pub static NO_QUOTES:Arg = Arg { short: None,          long: "no-quotes",takes_value: TakesValue::Forbidden };
+pub static ONE_LINE: Arg = Arg {
+    short: Some(b'1'),
+    long: "oneline",
+    takes_value: TakesValue::Forbidden,
+};
+pub static LONG: Arg = Arg {
+    short: Some(b'l'),
+    long: "long",
+    takes_value: TakesValue::Forbidden,
+};
+pub static GRID: Arg = Arg {
+    short: Some(b'G'),
+    long: "grid",
+    takes_value: TakesValue::Forbidden,
+};
+pub static ACROSS: Arg = Arg {
+    short: Some(b'x'),
+    long: "across",
+    takes_value: TakesValue::Forbidden,
+};
+pub static RECURSE: Arg = Arg {
+    short: Some(b'R'),
+    long: "recurse",
+    takes_value: TakesValue::Forbidden,
+};
+pub static TREE: Arg = Arg {
+    short: Some(b'T'),
+    long: "tree",
+    takes_value: TakesValue::Forbidden,
+};
+pub static CLASSIFY: Arg = Arg {
+    short: Some(b'F'),
+    long: "classify",
+    takes_value: TakesValue::Forbidden,
+};
+pub static DEREF_LINKS: Arg = Arg {
+    short: Some(b'X'),
+    long: "dereference",
+    takes_value: TakesValue::Forbidden,
+};
+pub static WIDTH: Arg = Arg {
+    short: Some(b'w'),
+    long: "width",
+    takes_value: TakesValue::Necessary(None),
+};
+pub static NO_QUOTES: Arg = Arg {
+    short: None,
+    long: "no-quotes",
+    takes_value: TakesValue::Forbidden,
+};
 
-pub static COLOR:  Arg = Arg { short: None, long: "color",  takes_value: TakesValue::Necessary(Some(COLOURS)) };
-pub static COLOUR: Arg = Arg { short: None, long: "colour", takes_value: TakesValue::Necessary(Some(COLOURS)) };
+pub static COLOR: Arg = Arg {
+    short: None,
+    long: "color",
+    takes_value: TakesValue::Necessary(Some(COLOURS)),
+};
+pub static COLOUR: Arg = Arg {
+    short: None,
+    long: "colour",
+    takes_value: TakesValue::Necessary(Some(COLOURS)),
+};
 const COLOURS: &[&str] = &["always", "auto", "never"];
 
-pub static COLOR_SCALE:  Arg = Arg { short: None, long: "color-scale",  takes_value: TakesValue::Forbidden };
-pub static COLOUR_SCALE: Arg = Arg { short: None, long: "colour-scale", takes_value: TakesValue::Forbidden };
+pub static COLOR_SCALE: Arg = Arg {
+    short: None,
+    long: "color-scale",
+    takes_value: TakesValue::Forbidden,
+};
+pub static COLOUR_SCALE: Arg = Arg {
+    short: None,
+    long: "colour-scale",
+    takes_value: TakesValue::Forbidden,
+};
 
 // filtering and sorting options
-pub static ALL:         Arg = Arg { short: Some(b'a'), long: "all",         takes_value: TakesValue::Forbidden };
-pub static ALMOST_ALL:  Arg = Arg { short: Some(b'A'), long: "almost-all",  takes_value: TakesValue::Forbidden };
-pub static LIST_DIRS:   Arg = Arg { short: Some(b'd'), long: "list-dirs",   takes_value: TakesValue::Forbidden };
-pub static LEVEL:       Arg = Arg { short: Some(b'L'), long: "level",       takes_value: TakesValue::Necessary(None) };
-pub static REVERSE:     Arg = Arg { short: Some(b'r'), long: "reverse",     takes_value: TakesValue::Forbidden };
-pub static SORT:        Arg = Arg { short: Some(b's'), long: "sort",        takes_value: TakesValue::Necessary(Some(SORTS)) };
-pub static IGNORE_GLOB: Arg = Arg { short: Some(b'I'), long: "ignore-glob", takes_value: TakesValue::Necessary(None) };
-pub static GIT_IGNORE:  Arg = Arg { short: None, long: "git-ignore",           takes_value: TakesValue::Forbidden };
-pub static DIRS_FIRST:  Arg = Arg { short: None, long: "group-directories-first",  takes_value: TakesValue::Forbidden };
-pub static ONLY_DIRS:   Arg = Arg { short: Some(b'D'), long: "only-dirs", takes_value: TakesValue::Forbidden };
-pub static ONLY_FILES:   Arg = Arg { short: Some(b'f'), long: "only-files", takes_value: TakesValue::Forbidden };
-const SORTS: Values = &[ "name", "Name", "size", "extension",
-                         "Extension", "modified", "changed", "accessed",
-                         "created", "inode", "type", "none" ];
+pub static ALL: Arg = Arg {
+    short: Some(b'a'),
+    long: "all",
+    takes_value: TakesValue::Forbidden,
+};
+pub static ALMOST_ALL: Arg = Arg {
+    short: Some(b'A'),
+    long: "almost-all",
+    takes_value: TakesValue::Forbidden,
+};
+pub static LIST_DIRS: Arg = Arg {
+    short: Some(b'd'),
+    long: "list-dirs",
+    takes_value: TakesValue::Forbidden,
+};
+pub static LEVEL: Arg = Arg {
+    short: Some(b'L'),
+    long: "level",
+    takes_value: TakesValue::Necessary(None),
+};
+pub static REVERSE: Arg = Arg {
+    short: Some(b'r'),
+    long: "reverse",
+    takes_value: TakesValue::Forbidden,
+};
+pub static SORT: Arg = Arg {
+    short: Some(b's'),
+    long: "sort",
+    takes_value: TakesValue::Necessary(Some(SORTS)),
+};
+pub static IGNORE_GLOB: Arg = Arg {
+    short: Some(b'I'),
+    long: "ignore-glob",
+    takes_value: TakesValue::Necessary(None),
+};
+pub static GIT_IGNORE: Arg = Arg {
+    short: None,
+    long: "git-ignore",
+    takes_value: TakesValue::Forbidden,
+};
+pub static DIRS_FIRST: Arg = Arg {
+    short: None,
+    long: "group-directories-first",
+    takes_value: TakesValue::Forbidden,
+};
+pub static ONLY_DIRS: Arg = Arg {
+    short: Some(b'D'),
+    long: "only-dirs",
+    takes_value: TakesValue::Forbidden,
+};
+pub static ONLY_FILES: Arg = Arg {
+    short: Some(b'f'),
+    long: "only-files",
+    takes_value: TakesValue::Forbidden,
+};
+const SORTS: Values = &[
+    "name",
+    "Name",
+    "size",
+    "extension",
+    "Extension",
+    "modified",
+    "changed",
+    "accessed",
+    "created",
+    "inode",
+    "type",
+    "none",
+];
 
 // display options
-pub static BINARY:      Arg = Arg { short: Some(b'b'), long: "binary",      takes_value: TakesValue::Forbidden };
-pub static BYTES:       Arg = Arg { short: Some(b'B'), long: "bytes",       takes_value: TakesValue::Forbidden };
-pub static GROUP:       Arg = Arg { short: Some(b'g'), long: "group",       takes_value: TakesValue::Forbidden };
-pub static NUMERIC:     Arg = Arg { short: Some(b'n'), long: "numeric",     takes_value: TakesValue::Forbidden };
-pub static HEADER:      Arg = Arg { short: Some(b'h'), long: "header",      takes_value: TakesValue::Forbidden };
-pub static ICONS:       Arg = Arg { short: None,       long: "icons",       takes_value: TakesValue::Forbidden };
-pub static INODE:       Arg = Arg { short: Some(b'i'), long: "inode",       takes_value: TakesValue::Forbidden };
-pub static LINKS:       Arg = Arg { short: Some(b'H'), long: "links",       takes_value: TakesValue::Forbidden };
-pub static MODIFIED:    Arg = Arg { short: Some(b'm'), long: "modified",    takes_value: TakesValue::Forbidden };
-pub static CHANGED:     Arg = Arg { short: None,       long: "changed",     takes_value: TakesValue::Forbidden };
-pub static BLOCKSIZE:   Arg = Arg { short: Some(b'S'), long: "blocksize",   takes_value: TakesValue::Forbidden };
-pub static TOTALSIZE:   Arg = Arg { short: None,       long: "totalsize",   takes_value: TakesValue::Forbidden };
-pub static TIME:        Arg = Arg { short: Some(b't'), long: "time",        takes_value: TakesValue::Necessary(Some(TIMES)) };
-pub static ACCESSED:    Arg = Arg { short: Some(b'u'), long: "accessed",    takes_value: TakesValue::Forbidden };
-pub static CREATED:     Arg = Arg { short: Some(b'U'), long: "created",     takes_value: TakesValue::Forbidden };
-pub static TIME_STYLE:  Arg = Arg { short: None,       long: "time-style",  takes_value: TakesValue::Necessary(Some(TIME_STYLES)) };
-pub static HYPERLINK:   Arg = Arg { short: None,       long: "hyperlink",   takes_value: TakesValue::Forbidden };
-pub static MOUNTS:      Arg = Arg { short: Some(b'M'), long: "mounts",      takes_value: TakesValue::Forbidden };
-pub static SMART_GROUP: Arg = Arg { short: None,       long: "smart-group", takes_value: TakesValue::Forbidden };
+pub static BINARY: Arg = Arg {
+    short: Some(b'b'),
+    long: "binary",
+    takes_value: TakesValue::Forbidden,
+};
+pub static BYTES: Arg = Arg {
+    short: Some(b'B'),
+    long: "bytes",
+    takes_value: TakesValue::Forbidden,
+};
+pub static GROUP: Arg = Arg {
+    short: Some(b'g'),
+    long: "group",
+    takes_value: TakesValue::Forbidden,
+};
+pub static NUMERIC: Arg = Arg {
+    short: Some(b'n'),
+    long: "numeric",
+    takes_value: TakesValue::Forbidden,
+};
+pub static HEADER: Arg = Arg {
+    short: Some(b'h'),
+    long: "header",
+    takes_value: TakesValue::Forbidden,
+};
+pub static ICONS: Arg = Arg {
+    short: None,
+    long: "icons",
+    takes_value: TakesValue::Forbidden,
+};
+pub static INODE: Arg = Arg {
+    short: Some(b'i'),
+    long: "inode",
+    takes_value: TakesValue::Forbidden,
+};
+pub static LINKS: Arg = Arg {
+    short: Some(b'H'),
+    long: "links",
+    takes_value: TakesValue::Forbidden,
+};
+pub static MODIFIED: Arg = Arg {
+    short: Some(b'm'),
+    long: "modified",
+    takes_value: TakesValue::Forbidden,
+};
+pub static CHANGED: Arg = Arg {
+    short: None,
+    long: "changed",
+    takes_value: TakesValue::Forbidden,
+};
+pub static BLOCKSIZE: Arg = Arg {
+    short: Some(b'S'),
+    long: "blocksize",
+    takes_value: TakesValue::Forbidden,
+};
+pub static TOTALSIZE: Arg = Arg {
+    short: None,
+    long: "totalsize",
+    takes_value: TakesValue::Forbidden,
+};
+pub static TIME: Arg = Arg {
+    short: Some(b't'),
+    long: "time",
+    takes_value: TakesValue::Necessary(Some(TIMES)),
+};
+pub static ACCESSED: Arg = Arg {
+    short: Some(b'u'),
+    long: "accessed",
+    takes_value: TakesValue::Forbidden,
+};
+pub static CREATED: Arg = Arg {
+    short: Some(b'U'),
+    long: "created",
+    takes_value: TakesValue::Forbidden,
+};
+pub static TIME_STYLE: Arg = Arg {
+    short: None,
+    long: "time-style",
+    takes_value: TakesValue::Necessary(Some(TIME_STYLES)),
+};
+pub static HYPERLINK: Arg = Arg {
+    short: None,
+    long: "hyperlink",
+    takes_value: TakesValue::Forbidden,
+};
+pub static MOUNTS: Arg = Arg {
+    short: Some(b'M'),
+    long: "mounts",
+    takes_value: TakesValue::Forbidden,
+};
+pub static SMART_GROUP: Arg = Arg {
+    short: None,
+    long: "smart-group",
+    takes_value: TakesValue::Forbidden,
+};
 const TIMES: Values = &["modified", "changed", "accessed", "created"];
 const TIME_STYLES: Values = &["default", "long-iso", "full-iso", "iso", "relative"];
 
 // 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 };
-pub static NO_ICONS: Arg = Arg { short: None, long: "no-icons", takes_value: TakesValue::Forbidden };
+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,
+};
+pub static NO_ICONS: Arg = Arg {
+    short: None,
+    long: "no-icons",
+    takes_value: TakesValue::Forbidden,
+};
 
 // optional feature options
-pub static GIT:               Arg = Arg { short: None,       long: "git",                  takes_value: TakesValue::Forbidden };
-pub static NO_GIT:            Arg = Arg { short: None,       long: "no-git",               takes_value: TakesValue::Forbidden };
-pub static GIT_REPOS:         Arg = Arg { short: None,       long: "git-repos",            takes_value: TakesValue::Forbidden };
-pub static GIT_REPOS_NO_STAT: Arg = Arg { short: None,       long: "git-repos-no-status",  takes_value: TakesValue::Forbidden };
-pub static EXTENDED:          Arg = Arg { short: Some(b'@'), long: "extended",             takes_value: TakesValue::Forbidden };
-pub static OCTAL:             Arg = Arg { short: Some(b'o'), long: "octal-permissions",    takes_value: TakesValue::Forbidden };
-pub static SECURITY_CONTEXT:  Arg = Arg { short: Some(b'Z'), long: "context",              takes_value: TakesValue::Forbidden };
+pub static GIT: Arg = Arg {
+    short: None,
+    long: "git",
+    takes_value: TakesValue::Forbidden,
+};
+pub static NO_GIT: Arg = Arg {
+    short: None,
+    long: "no-git",
+    takes_value: TakesValue::Forbidden,
+};
+pub static GIT_REPOS: Arg = Arg {
+    short: None,
+    long: "git-repos",
+    takes_value: TakesValue::Forbidden,
+};
+pub static GIT_REPOS_NO_STAT: Arg = Arg {
+    short: None,
+    long: "git-repos-no-status",
+    takes_value: TakesValue::Forbidden,
+};
+pub static EXTENDED: Arg = Arg {
+    short: Some(b'@'),
+    long: "extended",
+    takes_value: TakesValue::Forbidden,
+};
+pub static OCTAL: Arg = Arg {
+    short: Some(b'o'),
+    long: "octal-permissions",
+    takes_value: TakesValue::Forbidden,
+};
+pub static SECURITY_CONTEXT: Arg = Arg {
+    short: Some(b'Z'),
+    long: "context",
+    takes_value: TakesValue::Forbidden,
+};
 
 pub static ALL_ARGS: Args = Args(&[
-    &VERSION, &HELP,
-
-    &ONE_LINE, &LONG, &GRID, &ACROSS, &RECURSE, &TREE, &CLASSIFY, &DEREF_LINKS,
-    &COLOR, &COLOUR, &COLOR_SCALE, &COLOUR_SCALE, &WIDTH, &NO_QUOTES,
-
-    &ALL, &ALMOST_ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST,
-    &IGNORE_GLOB, &GIT_IGNORE, &ONLY_DIRS, &ONLY_FILES,
-
-    &BINARY, &BYTES, &GROUP, &NUMERIC, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,
-    &BLOCKSIZE, &TOTALSIZE, &TIME, &ACCESSED, &CREATED, &TIME_STYLE, &HYPERLINK, &MOUNTS,
-    &NO_PERMISSIONS, &NO_FILESIZE, &NO_USER, &NO_TIME, &NO_ICONS, &SMART_GROUP,
-
-    &GIT, &NO_GIT, &GIT_REPOS, &GIT_REPOS_NO_STAT,
-    &EXTENDED, &OCTAL, &SECURITY_CONTEXT
+    &VERSION,
+    &HELP,
+    &ONE_LINE,
+    &LONG,
+    &GRID,
+    &ACROSS,
+    &RECURSE,
+    &TREE,
+    &CLASSIFY,
+    &DEREF_LINKS,
+    &COLOR,
+    &COLOUR,
+    &COLOR_SCALE,
+    &COLOUR_SCALE,
+    &WIDTH,
+    &NO_QUOTES,
+    &ALL,
+    &ALMOST_ALL,
+    &LIST_DIRS,
+    &LEVEL,
+    &REVERSE,
+    &SORT,
+    &DIRS_FIRST,
+    &IGNORE_GLOB,
+    &GIT_IGNORE,
+    &ONLY_DIRS,
+    &ONLY_FILES,
+    &BINARY,
+    &BYTES,
+    &GROUP,
+    &NUMERIC,
+    &HEADER,
+    &ICONS,
+    &INODE,
+    &LINKS,
+    &MODIFIED,
+    &CHANGED,
+    &BLOCKSIZE,
+    &TOTALSIZE,
+    &TIME,
+    &ACCESSED,
+    &CREATED,
+    &TIME_STYLE,
+    &HYPERLINK,
+    &MOUNTS,
+    &NO_PERMISSIONS,
+    &NO_FILESIZE,
+    &NO_USER,
+    &NO_TIME,
+    &NO_ICONS,
+    &SMART_GROUP,
+    &GIT,
+    &NO_GIT,
+    &GIT_REPOS,
+    &GIT_REPOS_NO_STAT,
+    &EXTENDED,
+    &OCTAL,
+    &SECURITY_CONTEXT,
 ]);

+ 1 - 1
src/options/view.rs

@@ -21,7 +21,7 @@ impl View {
             width,
             file_style,
             deref_links,
-            total_size
+            total_size,
         })
     }
 }

+ 1 - 1
src/output/details.rs

@@ -135,7 +135,7 @@ pub struct Render<'a> {
 
     pub git: Option<&'a GitCache>,
 
-    pub total_size: bool
+    pub total_size: bool,
 }
 
 #[rustfmt::skip]

+ 4 - 2
src/output/grid_details.rs

@@ -86,7 +86,7 @@ pub struct Render<'a> {
 
     pub console_width: usize,
 
-    pub total_size: bool
+    pub total_size: bool,
 }
 
 impl<'a> Render<'a> {
@@ -157,7 +157,9 @@ impl<'a> Render<'a> {
         let rows = self
             .files
             .iter()
-            .map(|file| first_table.row_for_file(file, drender.show_xattr_hint(file), self.total_size))
+            .map(|file| {
+                first_table.row_for_file(file, drender.show_xattr_hint(file), self.total_size)
+            })
             .collect::<Vec<_>>();
 
         let file_names = self

+ 1 - 1
src/output/mod.rs

@@ -22,7 +22,7 @@ pub struct View {
     pub width: TerminalWidth,
     pub file_style: file_name::Options,
     pub deref_links: bool,
-    pub total_size: bool
+    pub total_size: bool,
 }
 
 /// The **mode** is the “type” of output.

+ 8 - 7
src/output/table.rs

@@ -453,13 +453,14 @@ impl<'a> Table<'a> {
     fn display(&self, file: &File<'_>, column: Column, xattrs: bool, total_size: bool) -> TextCell {
         match column {
             Column::Permissions => self.permissions_plus(file, xattrs).render(self.theme),
-            Column::FileSize => match total_size {
-                true => file
-                    .recursive_size()
-                    .render(self.theme, self.size_format, &self.env.numeric),
-                false => file
-                    .size()
-                    .render(self.theme, self.size_format, &self.env.numeric)
+            Column::FileSize => {
+                if total_size {
+                    file.recursive_size()
+                        .render(self.theme, self.size_format, &self.env.numeric)
+                } else {
+                    file.size()
+                        .render(self.theme, self.size_format, &self.env.numeric)
+                }
             }
             #[cfg(unix)]
             Column::HardLinks => file.links().render(self.theme, &self.env.numeric),