mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-11 16:34:26 +00:00
Add none and inode sort options
This commit is contained in:
parent
35a0ba3ba0
commit
e2f9a80ca5
@ -22,10 +22,12 @@ Options
|
|||||||
- **-i**, **--inode**: show inode number column
|
- **-i**, **--inode**: show inode number column
|
||||||
- **-l**, **--long**: display extended details and attributes
|
- **-l**, **--long**: display extended details and attributes
|
||||||
- **-r**, **--reverse**: reverse sort order
|
- **-r**, **--reverse**: reverse sort order
|
||||||
- **-s**, **--sort=(name, size, ext)**: field to sort by
|
- **-s**, **--sort=(field)**: field to sort by
|
||||||
- **-S**, **--blocks**: show number of file system blocks
|
- **-S**, **--blocks**: show number of file system blocks
|
||||||
- **-x**, **--across**: sort multi-column view entries across
|
- **-x**, **--across**: sort multi-column view entries across
|
||||||
|
|
||||||
|
You can sort by **name**, **size**, **ext**, **inode**, or **none**.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -6,16 +6,18 @@ use std::ascii::StrAsciiExt;
|
|||||||
use term;
|
use term;
|
||||||
|
|
||||||
pub enum SortField {
|
pub enum SortField {
|
||||||
Name, Extension, Size
|
Unsorted, Name, Extension, Size, FileInode
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SortField {
|
impl SortField {
|
||||||
fn from_word(word: String) -> SortField {
|
fn from_word(word: String) -> SortField {
|
||||||
match word.as_slice() {
|
match word.as_slice() {
|
||||||
"name" => Name,
|
"name" => Name,
|
||||||
"size" => Size,
|
"size" => Size,
|
||||||
"ext" => Extension,
|
"ext" => Extension,
|
||||||
_ => fail!("Invalid sorting order"),
|
"none" => Unsorted,
|
||||||
|
"inode" => FileInode,
|
||||||
|
_ => fail!("Invalid sorting order"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,8 +127,10 @@ impl Options {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
match self.sort_field {
|
match self.sort_field {
|
||||||
|
Unsorted => {},
|
||||||
Name => files.sort_by(|a, b| a.parts.cmp(&b.parts)),
|
Name => files.sort_by(|a, b| a.parts.cmp(&b.parts)),
|
||||||
Size => files.sort_by(|a, b| a.stat.size.cmp(&b.stat.size)),
|
Size => files.sort_by(|a, b| a.stat.size.cmp(&b.stat.size)),
|
||||||
|
FileInode => files.sort_by(|a, b| a.stat.unstable.inode.cmp(&b.stat.unstable.inode)),
|
||||||
Extension => files.sort_by(|a, b| {
|
Extension => files.sort_by(|a, b| {
|
||||||
let exts = a.ext.clone().map(|e| e.as_slice().to_ascii_lower()).cmp(&b.ext.clone().map(|e| e.as_slice().to_ascii_lower()));
|
let exts = a.ext.clone().map(|e| e.as_slice().to_ascii_lower()).cmp(&b.ext.clone().map(|e| e.as_slice().to_ascii_lower()));
|
||||||
let names = a.name.as_slice().to_ascii_lower().cmp(&b.name.as_slice().to_ascii_lower());
|
let names = a.name.as_slice().to_ascii_lower().cmp(&b.name.as_slice().to_ascii_lower());
|
||||||
|
Loading…
Reference in New Issue
Block a user