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();
|
let mut first = files.is_empty();
|
||||||
|
|
||||||
if !files.is_empty() {
|
if !files.is_empty() {
|
||||||
options.view.view(files);
|
options.view(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
for dir_name in dirs.iter() {
|
for dir_name in dirs.iter() {
|
||||||
@ -74,7 +74,7 @@ fn exa(options: &Options) {
|
|||||||
println!("{}:", dir_name);
|
println!("{}:", dir_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
options.view.view(files);
|
options.view(files);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("{}: {}", dir_name, e);
|
println!("{}: {}", dir_name, e);
|
||||||
|
@ -18,11 +18,11 @@ use self::Misfire::*;
|
|||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
pub list_dirs: bool,
|
pub list_dirs: bool,
|
||||||
pub path_strs: Vec<String>,
|
path_strs: Vec<String>,
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
show_invisibles: bool,
|
show_invisibles: bool,
|
||||||
sort_field: SortField,
|
sort_field: SortField,
|
||||||
pub view: View,
|
view: View,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
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> {
|
pub fn path_strings(&self) -> Iter<String> {
|
||||||
self.path_strs.iter()
|
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.
|
/// Transform the files somehow before listing them.
|
||||||
pub fn transform_files<'a>(&self, mut files: Vec<File<'a>>) -> Vec<File<'a>> {
|
pub fn transform_files<'a>(&self, mut files: Vec<File<'a>>) -> Vec<File<'a>> {
|
||||||
|
|
||||||
@ -284,14 +290,16 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn files() {
|
fn files() {
|
||||||
let opts = Options::getopts(&[ "this file".to_string(), "that file".to_string() ]);
|
let opts = Options::getopts(&[ "this file".to_string(), "that file".to_string() ]).unwrap();
|
||||||
assert_eq!(opts.unwrap().path_strs, vec![ "this file".to_string(), "that file".to_string() ])
|
let args: Vec<&String> = opts.path_strings().collect();
|
||||||
|
assert_eq!(args, vec![ &"this file".to_string(), &"that file".to_string() ])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_args() {
|
fn no_args() {
|
||||||
let opts = Options::getopts(&[]);
|
let opts = Options::getopts(&[]).unwrap();
|
||||||
assert_eq!(opts.unwrap().path_strs, vec![ ".".to_string() ])
|
let args: Vec<&String> = opts.path_strings().collect();
|
||||||
|
assert_eq!(args, vec![ &".".to_string() ])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user