diff --git a/exa.rs b/exa.rs index ccb8719..b0ffcf5 100644 --- a/exa.rs +++ b/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> = files.iter() diff --git a/options.rs b/options.rs index 7c30185..fce4cde 100644 --- a/options.rs +++ b/options.rs @@ -8,6 +8,7 @@ pub enum SortField { pub struct Options { pub showInvisibles: bool, pub sortField: SortField, + pub reverse: bool, } impl SortField {