mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-16 01:07:09 +00:00
Make some fields private
This commit is contained in:
parent
709fb71e69
commit
64c1600cd4
@ -54,7 +54,7 @@ fn exa(options: &Options) {
|
||||
let mut first = files.is_empty();
|
||||
|
||||
if !files.is_empty() {
|
||||
options.view.view(files);
|
||||
options.view(files);
|
||||
}
|
||||
|
||||
for dir_name in dirs.iter() {
|
||||
@ -74,7 +74,7 @@ fn exa(options: &Options) {
|
||||
println!("{}:", dir_name);
|
||||
}
|
||||
|
||||
options.view.view(files);
|
||||
options.view(files);
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}: {}", dir_name, e);
|
||||
|
@ -18,11 +18,11 @@ use self::Misfire::*;
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub struct Options {
|
||||
pub list_dirs: bool,
|
||||
pub path_strs: Vec<String>,
|
||||
path_strs: Vec<String>,
|
||||
reverse: bool,
|
||||
show_invisibles: bool,
|
||||
sort_field: SortField,
|
||||
pub view: View,
|
||||
view: View,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
@ -71,10 +71,16 @@ impl Options {
|
||||
})
|
||||
}
|
||||
|
||||
/// Iterate over the non-option arguments left oven from getopts.
|
||||
pub fn path_strings(&self) -> Iter<String> {
|
||||
self.path_strs.iter()
|
||||
}
|
||||
|
||||
/// Display the files using this Option's View.
|
||||
pub fn view(&self, files: Vec<File>) {
|
||||
self.view.view(files)
|
||||
}
|
||||
|
||||
/// Transform the files somehow before listing them.
|
||||
pub fn transform_files<'a>(&self, mut files: Vec<File<'a>>) -> Vec<File<'a>> {
|
||||
|
||||
@ -284,14 +290,16 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn files() {
|
||||
let opts = Options::getopts(&[ "this file".to_string(), "that file".to_string() ]);
|
||||
assert_eq!(opts.unwrap().path_strs, vec![ "this file".to_string(), "that file".to_string() ])
|
||||
let opts = Options::getopts(&[ "this file".to_string(), "that file".to_string() ]).unwrap();
|
||||
let args: Vec<&String> = opts.path_strings().collect();
|
||||
assert_eq!(args, vec![ &"this file".to_string(), &"that file".to_string() ])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_args() {
|
||||
let opts = Options::getopts(&[]);
|
||||
assert_eq!(opts.unwrap().path_strs, vec![ ".".to_string() ])
|
||||
let opts = Options::getopts(&[]).unwrap();
|
||||
let args: Vec<&String> = opts.path_strings().collect();
|
||||
assert_eq!(args, vec![ &".".to_string() ])
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user