mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-24 17:40:25 +00:00
Move columns to options object
This commit is contained in:
parent
cb6dd57ca0
commit
566ed0bba8
10
column.rs
10
column.rs
@ -5,13 +5,3 @@ pub enum Column {
|
||||
User,
|
||||
Group,
|
||||
}
|
||||
|
||||
pub fn defaultColumns() -> ~[Column] {
|
||||
return ~[
|
||||
Permissions,
|
||||
FileSize(false),
|
||||
User,
|
||||
Group,
|
||||
FileName,
|
||||
];
|
||||
}
|
||||
|
5
exa.rs
5
exa.rs
@ -6,7 +6,6 @@ use std::os;
|
||||
use std::io::fs;
|
||||
|
||||
use file::File;
|
||||
use column::defaultColumns;
|
||||
use options::Options;
|
||||
|
||||
pub mod colours;
|
||||
@ -50,7 +49,7 @@ fn exa(options: &Options, path: Path) {
|
||||
files.reverse();
|
||||
}
|
||||
|
||||
let columns = defaultColumns();
|
||||
let columns = options.columns();
|
||||
|
||||
let table: Vec<Vec<StrBuf>> = files.iter()
|
||||
.filter(|&f| options.show(f))
|
||||
@ -58,7 +57,7 @@ fn exa(options: &Options, path: Path) {
|
||||
.collect();
|
||||
|
||||
let lengths: Vec<Vec<uint>> = table.iter()
|
||||
.map(|row| row.iter().map( |col| colours::strip_formatting(col).len() ).collect())
|
||||
.map(|row| row.iter().map(|col| colours::strip_formatting(col).len() ).collect())
|
||||
.collect();
|
||||
|
||||
let maxes: Vec<uint> = range(0, columns.len())
|
||||
|
12
options.rs
12
options.rs
@ -2,6 +2,7 @@ extern crate getopts;
|
||||
|
||||
use file::File;
|
||||
use std::cmp::lexical_ordering;
|
||||
use column::{Column, Permissions, FileName, FileSize, User, Group};
|
||||
|
||||
pub enum SortField {
|
||||
Name, Extension, Size
|
||||
@ -67,4 +68,15 @@ impl Options {
|
||||
!f.name.starts_with(".")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn columns(&self) -> ~[Column] {
|
||||
return ~[
|
||||
Permissions,
|
||||
FileSize(false),
|
||||
User,
|
||||
Group,
|
||||
FileName,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user