|
|
@@ -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
|