mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-02-04 19:48:25 +00:00
Options and FileFilter are also deducible
We may as well use this trait now that it’s available!
This commit is contained in:
parent
534d3c3fa5
commit
2efaf7ec45
@ -83,15 +83,6 @@ impl Options {
|
||||
return Err(Misfire::Version);
|
||||
}
|
||||
|
||||
let sort_field = try!(SortField::deduce(&matches));
|
||||
|
||||
let filter = FileFilter {
|
||||
list_dirs_first: matches.opt_present("group-directories-first"),
|
||||
reverse: matches.opt_present("reverse"),
|
||||
show_invisibles: matches.opt_present("all"),
|
||||
sort_field: sort_field,
|
||||
};
|
||||
|
||||
let path_strs = if matches.free.is_empty() {
|
||||
vec![ ".".to_string() ]
|
||||
}
|
||||
@ -99,14 +90,8 @@ impl Options {
|
||||
matches.free.clone()
|
||||
};
|
||||
|
||||
let dir_action = try!(DirAction::deduce(&matches));
|
||||
let view = try!(View::deduce(&matches, filter, dir_action));
|
||||
|
||||
Ok((Options {
|
||||
dir_action: dir_action,
|
||||
view: view,
|
||||
filter: filter,
|
||||
}, path_strs))
|
||||
let options = try!(Options::deduce(&matches));
|
||||
Ok((options, path_strs))
|
||||
}
|
||||
|
||||
/// Whether the View specified in this set of options includes a Git
|
||||
@ -121,6 +106,20 @@ impl Options {
|
||||
}
|
||||
}
|
||||
|
||||
impl OptionSet for Options {
|
||||
fn deduce(matches: &getopts::Matches) -> Result<Options, Misfire> {
|
||||
let dir_action = try!(DirAction::deduce(&matches));
|
||||
let filter = try!(FileFilter::deduce(&matches));
|
||||
let view = try!(View::deduce(&matches, filter, dir_action));
|
||||
|
||||
Ok(Options {
|
||||
dir_action: dir_action,
|
||||
view: view,
|
||||
filter: filter,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||
pub enum View {
|
||||
@ -276,6 +275,19 @@ pub struct FileFilter {
|
||||
sort_field: SortField,
|
||||
}
|
||||
|
||||
impl OptionSet for FileFilter {
|
||||
fn deduce(matches: &getopts::Matches) -> Result<FileFilter, Misfire> {
|
||||
let sort_field = try!(SortField::deduce(&matches));
|
||||
|
||||
Ok(FileFilter {
|
||||
list_dirs_first: matches.opt_present("group-directories-first"),
|
||||
reverse: matches.opt_present("reverse"),
|
||||
show_invisibles: matches.opt_present("all"),
|
||||
sort_field: sort_field,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl FileFilter {
|
||||
|
||||
/// Remove every file in the given vector that does *not* pass the
|
||||
|
Loading…
x
Reference in New Issue
Block a user