mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-24 17:40:25 +00:00
Add reverse parameter
This commit is contained in:
parent
4d1aea12b0
commit
d60c2ce839
5
exa.rs
5
exa.rs
@ -24,6 +24,7 @@ fn main() {
|
||||
|
||||
let opts = ~[
|
||||
getopts::optflag("a", "all", "show dot-files"),
|
||||
getopts::optflag("r", "reverse", "reverse order of files"),
|
||||
getopts::optopt("s", "sort", "field to sort by", "WORD"),
|
||||
];
|
||||
|
||||
@ -34,6 +35,7 @@ fn main() {
|
||||
|
||||
let opts = Options {
|
||||
showInvisibles: matches.opt_present("all"),
|
||||
reverse: matches.opt_present("reverse"),
|
||||
sortField: matches.opt_str("sort").map(|word| SortField::from_word(word)).unwrap_or(Name),
|
||||
};
|
||||
|
||||
@ -57,6 +59,9 @@ fn list(options: Options, path: Path) {
|
||||
|
||||
let mut files = paths.iter().map(|path| File::from_path(path)).collect();
|
||||
options.sort(&mut files);
|
||||
if options.reverse {
|
||||
files.reverse();
|
||||
}
|
||||
|
||||
let columns = defaultColumns();
|
||||
let table: Vec<Vec<StrBuf>> = files.iter()
|
||||
|
@ -8,6 +8,7 @@ pub enum SortField {
|
||||
pub struct Options {
|
||||
pub showInvisibles: bool,
|
||||
pub sortField: SortField,
|
||||
pub reverse: bool,
|
||||
}
|
||||
|
||||
impl SortField {
|
||||
|
Loading…
Reference in New Issue
Block a user