mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-15 16:57:08 +00:00
Minor whitespace changes
This commit is contained in:
parent
b0d4c9728f
commit
2a3045ddfa
@ -52,12 +52,12 @@ impl Git {
|
|||||||
/// The character to display if the file has been modified, but not staged.
|
/// The character to display if the file has been modified, but not staged.
|
||||||
fn working_tree_status(status: git2::Status) -> file::GitStatus {
|
fn working_tree_status(status: git2::Status) -> file::GitStatus {
|
||||||
match status {
|
match status {
|
||||||
s if s.contains(git2::STATUS_WT_NEW) => file::GitStatus::New,
|
s if s.contains(git2::STATUS_WT_NEW) => file::GitStatus::New,
|
||||||
s if s.contains(git2::STATUS_WT_MODIFIED) => file::GitStatus::Modified,
|
s if s.contains(git2::STATUS_WT_MODIFIED) => file::GitStatus::Modified,
|
||||||
s if s.contains(git2::STATUS_WT_DELETED) => file::GitStatus::Deleted,
|
s if s.contains(git2::STATUS_WT_DELETED) => file::GitStatus::Deleted,
|
||||||
s if s.contains(git2::STATUS_WT_RENAMED) => file::GitStatus::Renamed,
|
s if s.contains(git2::STATUS_WT_RENAMED) => file::GitStatus::Renamed,
|
||||||
s if s.contains(git2::STATUS_WT_TYPECHANGE) => file::GitStatus::TypeChange,
|
s if s.contains(git2::STATUS_WT_TYPECHANGE) => file::GitStatus::TypeChange,
|
||||||
_ => file::GitStatus::NotModified,
|
_ => file::GitStatus::NotModified,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,11 +65,11 @@ fn working_tree_status(status: git2::Status) -> file::GitStatus {
|
|||||||
/// has been staged.
|
/// has been staged.
|
||||||
fn index_status(status: git2::Status) -> file::GitStatus {
|
fn index_status(status: git2::Status) -> file::GitStatus {
|
||||||
match status {
|
match status {
|
||||||
s if s.contains(git2::STATUS_INDEX_NEW) => file::GitStatus::New,
|
s if s.contains(git2::STATUS_INDEX_NEW) => file::GitStatus::New,
|
||||||
s if s.contains(git2::STATUS_INDEX_MODIFIED) => file::GitStatus::Modified,
|
s if s.contains(git2::STATUS_INDEX_MODIFIED) => file::GitStatus::Modified,
|
||||||
s if s.contains(git2::STATUS_INDEX_DELETED) => file::GitStatus::Deleted,
|
s if s.contains(git2::STATUS_INDEX_DELETED) => file::GitStatus::Deleted,
|
||||||
s if s.contains(git2::STATUS_INDEX_RENAMED) => file::GitStatus::Renamed,
|
s if s.contains(git2::STATUS_INDEX_RENAMED) => file::GitStatus::Renamed,
|
||||||
s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => file::GitStatus::TypeChange,
|
s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => file::GitStatus::TypeChange,
|
||||||
_ => file::GitStatus::NotModified,
|
_ => file::GitStatus::NotModified,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,17 +135,17 @@ impl FileFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match self.sort_field {
|
match self.sort_field {
|
||||||
SortField::Unsorted => {},
|
SortField::Unsorted => {},
|
||||||
SortField::Name => files.sort_by(|a, b| natord::compare(&*a.name, &*b.name)),
|
SortField::Name => files.sort_by(|a, b| natord::compare(&*a.name, &*b.name)),
|
||||||
SortField::Size => files.sort_by(|a, b| a.stat.len().cmp(&b.stat.len())),
|
SortField::Size => files.sort_by(|a, b| a.stat.len().cmp(&b.stat.len())),
|
||||||
SortField::FileInode => files.sort_by(|a, b| a.stat.as_raw().ino().cmp(&b.stat.as_raw().ino())),
|
SortField::FileInode => files.sort_by(|a, b| a.stat.as_raw().ino().cmp(&b.stat.as_raw().ino())),
|
||||||
SortField::Extension => files.sort_by(|a, b| match a.ext.cmp(&b.ext) {
|
SortField::ModifiedDate => files.sort_by(|a, b| a.stat.as_raw().mtime().cmp(&b.stat.as_raw().mtime())),
|
||||||
Ordering::Equal => natord::compare(&*a.name, &*b.name),
|
SortField::AccessedDate => files.sort_by(|a, b| a.stat.as_raw().atime().cmp(&b.stat.as_raw().atime())),
|
||||||
order => order
|
SortField::CreatedDate => files.sort_by(|a, b| a.stat.as_raw().ctime().cmp(&b.stat.as_raw().ctime())),
|
||||||
|
SortField::Extension => files.sort_by(|a, b| match a.ext.cmp(&b.ext) {
|
||||||
|
Ordering::Equal => natord::compare(&*a.name, &*b.name),
|
||||||
|
order => order,
|
||||||
}),
|
}),
|
||||||
SortField::ModifiedDate => files.sort_by(|a, b| a.stat.as_raw().mtime().cmp(&b.stat.as_raw().mtime())),
|
|
||||||
SortField::AccessedDate => files.sort_by(|a, b| a.stat.as_raw().atime().cmp(&b.stat.as_raw().atime())),
|
|
||||||
SortField::CreatedDate => files.sort_by(|a, b| a.stat.as_raw().ctime().cmp(&b.stat.as_raw().ctime())),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.reverse {
|
if self.reverse {
|
||||||
@ -171,15 +171,15 @@ impl SortField {
|
|||||||
/// Find which field to use based on a user-supplied word.
|
/// Find which field to use based on a user-supplied word.
|
||||||
fn from_word(word: String) -> Result<SortField, Misfire> {
|
fn from_word(word: String) -> Result<SortField, Misfire> {
|
||||||
match &word[..] {
|
match &word[..] {
|
||||||
"name" | "filename" => Ok(SortField::Name),
|
"name" | "filename" => Ok(SortField::Name),
|
||||||
"size" | "filesize" => Ok(SortField::Size),
|
"size" | "filesize" => Ok(SortField::Size),
|
||||||
"ext" | "extension" => Ok(SortField::Extension),
|
"ext" | "extension" => Ok(SortField::Extension),
|
||||||
"mod" | "modified" => Ok(SortField::ModifiedDate),
|
"mod" | "modified" => Ok(SortField::ModifiedDate),
|
||||||
"acc" | "accessed" => Ok(SortField::AccessedDate),
|
"acc" | "accessed" => Ok(SortField::AccessedDate),
|
||||||
"cr" | "created" => Ok(SortField::CreatedDate),
|
"cr" | "created" => Ok(SortField::CreatedDate),
|
||||||
"none" => Ok(SortField::Unsorted),
|
"none" => Ok(SortField::Unsorted),
|
||||||
"inode" => Ok(SortField::FileInode),
|
"inode" => Ok(SortField::FileInode),
|
||||||
field => Err(SortField::none(field))
|
field => Err(SortField::none(field))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,14 +229,14 @@ impl Misfire {
|
|||||||
impl fmt::Display for Misfire {
|
impl fmt::Display for Misfire {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
InvalidOptions(ref e) => write!(f, "{}", e),
|
InvalidOptions(ref e) => write!(f, "{}", e),
|
||||||
Help(ref text) => write!(f, "{}", text),
|
Help(ref text) => write!(f, "{}", text),
|
||||||
Version => write!(f, "exa {}", env!("CARGO_PKG_VERSION")),
|
Version => write!(f, "exa {}", env!("CARGO_PKG_VERSION")),
|
||||||
Conflict(a, b) => write!(f, "Option --{} conflicts with option {}.", a, b),
|
Conflict(a, b) => write!(f, "Option --{} conflicts with option {}.", a, b),
|
||||||
Useless(a, false, b) => write!(f, "Option --{} is useless without option --{}.", a, b),
|
Useless(a, false, b) => write!(f, "Option --{} is useless without option --{}.", a, b),
|
||||||
Useless(a, true, b) => write!(f, "Option --{} is useless given option --{}.", a, b),
|
Useless(a, true, b) => write!(f, "Option --{} is useless given option --{}.", a, b),
|
||||||
Useless2(a, b1, b2) => write!(f, "Option --{} is useless without options --{} or --{}.", a, b1, b2),
|
Useless2(a, b1, b2) => write!(f, "Option --{} is useless without options --{} or --{}.", a, b1, b2),
|
||||||
FailedParse(ref e) => write!(f, "Failed to parse number: {}", e),
|
FailedParse(ref e) => write!(f, "Failed to parse number: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,10 +349,10 @@ impl SizeFormat {
|
|||||||
let bytes = matches.opt_present("bytes");
|
let bytes = matches.opt_present("bytes");
|
||||||
|
|
||||||
match (binary, bytes) {
|
match (binary, bytes) {
|
||||||
(true, true ) => Err(Misfire::Conflict("binary", "bytes")),
|
(true, true ) => Err(Misfire::Conflict("binary", "bytes")),
|
||||||
(true, false) => Ok(SizeFormat::BinaryBytes),
|
(true, false) => Ok(SizeFormat::BinaryBytes),
|
||||||
(false, true ) => Ok(SizeFormat::JustBytes),
|
(false, true ) => Ok(SizeFormat::JustBytes),
|
||||||
(false, false) => Ok(SizeFormat::DecimalBytes),
|
(false, false) => Ok(SizeFormat::DecimalBytes),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,9 +367,9 @@ pub enum TimeType {
|
|||||||
impl TimeType {
|
impl TimeType {
|
||||||
pub fn header(&self) -> &'static str {
|
pub fn header(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
TimeType::FileAccessed => "Date Accessed",
|
TimeType::FileAccessed => "Date Accessed",
|
||||||
TimeType::FileModified => "Date Modified",
|
TimeType::FileModified => "Date Modified",
|
||||||
TimeType::FileCreated => "Date Created",
|
TimeType::FileCreated => "Date Created",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,12 +439,12 @@ impl DirAction {
|
|||||||
let tree = matches.opt_present("tree");
|
let tree = matches.opt_present("tree");
|
||||||
|
|
||||||
match (recurse, list, tree) {
|
match (recurse, list, tree) {
|
||||||
(true, true, _ ) => Err(Misfire::Conflict("recurse", "list-dirs")),
|
(true, true, _ ) => Err(Misfire::Conflict("recurse", "list-dirs")),
|
||||||
(_, true, true ) => Err(Misfire::Conflict("tree", "list-dirs")),
|
(_, true, true ) => Err(Misfire::Conflict("tree", "list-dirs")),
|
||||||
(true, false, false) => Ok(DirAction::Recurse(try!(RecurseOptions::deduce(matches, false)))),
|
(true, false, false) => Ok(DirAction::Recurse(try!(RecurseOptions::deduce(matches, false)))),
|
||||||
(_ , _, true ) => Ok(DirAction::Recurse(try!(RecurseOptions::deduce(matches, true)))),
|
(_ , _, true ) => Ok(DirAction::Recurse(try!(RecurseOptions::deduce(matches, true)))),
|
||||||
(false, true, _ ) => Ok(DirAction::AsFile),
|
(false, true, _ ) => Ok(DirAction::AsFile),
|
||||||
(false, false, _ ) => Ok(DirAction::List),
|
(false, false, _ ) => Ok(DirAction::List),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,6 @@ impl Table {
|
|||||||
users: OSUsers::empty_cache(),
|
users: OSUsers::empty_cache(),
|
||||||
colours: colours,
|
colours: colours,
|
||||||
current_year: LocalDateTime::now().year(),
|
current_year: LocalDateTime::now().year(),
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +172,7 @@ impl Table {
|
|||||||
children: file.this.is_some(),
|
children: file.this.is_some(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.rows.push(row)
|
self.rows.push(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use the list of columns to find which cells should be produced for
|
/// Use the list of columns to find which cells should be produced for
|
||||||
@ -205,11 +204,11 @@ impl Table {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let file_type = match permissions.file_type {
|
let file_type = match permissions.file_type {
|
||||||
Type::File => self.colours.filetypes.normal.paint("."),
|
Type::File => self.colours.filetypes.normal.paint("."),
|
||||||
Type::Directory => self.colours.filetypes.directory.paint("d"),
|
Type::Directory => self.colours.filetypes.directory.paint("d"),
|
||||||
Type::Pipe => self.colours.filetypes.special.paint("|"),
|
Type::Pipe => self.colours.filetypes.special.paint("|"),
|
||||||
Type::Link => self.colours.filetypes.symlink.paint("l"),
|
Type::Link => self.colours.filetypes.symlink.paint("l"),
|
||||||
Type::Special => self.colours.filetypes.special.paint("?"),
|
Type::Special => self.colours.filetypes.special.paint("?"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let x_colour = if let Type::File = permissions.file_type { c.user_execute_file }
|
let x_colour = if let Type::File = permissions.file_type { c.user_execute_file }
|
||||||
@ -244,8 +243,8 @@ impl Table {
|
|||||||
|
|
||||||
fn render_blocks(&self, blocks: Blocks) -> Cell {
|
fn render_blocks(&self, blocks: Blocks) -> Cell {
|
||||||
match blocks {
|
match blocks {
|
||||||
Blocks::Some(blocks) => Cell::paint(self.colours.blocks, &blocks.to_string()),
|
Blocks::Some(blocks) => Cell::paint(self.colours.blocks, &blocks.to_string()),
|
||||||
Blocks::None => Cell::paint(self.colours.punctuation, "-"),
|
Blocks::None => Cell::paint(self.colours.punctuation, "-"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,14 +255,14 @@ impl Table {
|
|||||||
fn render_size(&self, size: Size, size_format: SizeFormat) -> Cell {
|
fn render_size(&self, size: Size, size_format: SizeFormat) -> Cell {
|
||||||
if let Size::Some(offset) = size {
|
if let Size::Some(offset) = size {
|
||||||
let result = match size_format {
|
let result = match size_format {
|
||||||
SizeFormat::DecimalBytes => decimal_prefix(offset as f64),
|
SizeFormat::DecimalBytes => decimal_prefix(offset as f64),
|
||||||
SizeFormat::BinaryBytes => binary_prefix(offset as f64),
|
SizeFormat::BinaryBytes => binary_prefix(offset as f64),
|
||||||
SizeFormat::JustBytes => return Cell::paint(self.colours.size.numbers, &self.numeric.format_int(offset)),
|
SizeFormat::JustBytes => return Cell::paint(self.colours.size.numbers, &self.numeric.format_int(offset)),
|
||||||
};
|
};
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Standalone(bytes) => Cell::paint(self.colours.size.numbers, &*bytes.to_string()),
|
Standalone(bytes) => Cell::paint(self.colours.size.numbers, &*bytes.to_string()),
|
||||||
Prefixed(prefix, n) => {
|
Prefixed(prefix, n) => {
|
||||||
let number = if n < 10f64 { self.numeric.format_float(n, 1) } else { self.numeric.format_int(n as isize) };
|
let number = if n < 10f64 { self.numeric.format_float(n, 1) } else { self.numeric.format_int(n as isize) };
|
||||||
let symbol = prefix.symbol();
|
let symbol = prefix.symbol();
|
||||||
|
|
||||||
@ -295,12 +294,12 @@ impl Table {
|
|||||||
fn render_git_status(&self, git: Git) -> Cell {
|
fn render_git_status(&self, git: Git) -> Cell {
|
||||||
let render_char = |chr| {
|
let render_char = |chr| {
|
||||||
match chr {
|
match chr {
|
||||||
GitStatus::NotModified => self.colours.punctuation.paint("-"),
|
GitStatus::NotModified => self.colours.punctuation.paint("-"),
|
||||||
GitStatus::New => self.colours.git.renamed.paint("N"),
|
GitStatus::New => self.colours.git.renamed.paint("N"),
|
||||||
GitStatus::Modified => self.colours.git.renamed.paint("M"),
|
GitStatus::Modified => self.colours.git.renamed.paint("M"),
|
||||||
GitStatus::Deleted => self.colours.git.renamed.paint("D"),
|
GitStatus::Deleted => self.colours.git.renamed.paint("D"),
|
||||||
GitStatus::Renamed => self.colours.git.renamed.paint("R"),
|
GitStatus::Renamed => self.colours.git.renamed.paint("R"),
|
||||||
GitStatus::TypeChange => self.colours.git.renamed.paint("T"),
|
GitStatus::TypeChange => self.colours.git.renamed.paint("T"),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -312,8 +311,8 @@ impl Table {
|
|||||||
|
|
||||||
fn render_user(&mut self, user: User) -> Cell {
|
fn render_user(&mut self, user: User) -> Cell {
|
||||||
let user_name = match self.users.get_user_by_uid(user.0) {
|
let user_name = match self.users.get_user_by_uid(user.0) {
|
||||||
Some(user) => user.name,
|
Some(user) => user.name,
|
||||||
None => user.0.to_string(),
|
None => user.0.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let style = if self.users.get_current_uid() == user.0 { self.colours.users.user_you }
|
let style = if self.users.get_current_uid() == user.0 { self.colours.users.user_you }
|
||||||
@ -416,10 +415,10 @@ enum TreePart {
|
|||||||
impl TreePart {
|
impl TreePart {
|
||||||
fn ascii_art(&self) -> &'static str {
|
fn ascii_art(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
TreePart::Edge => "├──",
|
TreePart::Edge => "├──",
|
||||||
TreePart::Line => "│ ",
|
TreePart::Line => "│ ",
|
||||||
TreePart::Corner => "└──",
|
TreePart::Corner => "└──",
|
||||||
TreePart::Blank => " ",
|
TreePart::Blank => " ",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user