mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-24 01:25:28 +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
|
||||
- **-l**, **--long**: display extended details and attributes
|
||||
- **-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
|
||||
- **-x**, **--across**: sort multi-column view entries across
|
||||
|
||||
You can sort by **name**, **size**, **ext**, **inode**, or **none**.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
|
@ -6,16 +6,18 @@ use std::ascii::StrAsciiExt;
|
||||
use term;
|
||||
|
||||
pub enum SortField {
|
||||
Name, Extension, Size
|
||||
Unsorted, Name, Extension, Size, FileInode
|
||||
}
|
||||
|
||||
impl SortField {
|
||||
fn from_word(word: String) -> SortField {
|
||||
match word.as_slice() {
|
||||
"name" => Name,
|
||||
"size" => Size,
|
||||
"ext" => Extension,
|
||||
_ => fail!("Invalid sorting order"),
|
||||
"name" => Name,
|
||||
"size" => Size,
|
||||
"ext" => Extension,
|
||||
"none" => Unsorted,
|
||||
"inode" => FileInode,
|
||||
_ => fail!("Invalid sorting order"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,8 +127,10 @@ impl Options {
|
||||
.collect();
|
||||
|
||||
match self.sort_field {
|
||||
Unsorted => {},
|
||||
Name => files.sort_by(|a, b| a.parts.cmp(&b.parts)),
|
||||
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| {
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user