diff options
author | Ben S <ogham@bsago.me> | 2015-05-16 21:02:28 +0100 |
---|---|---|
committer | Ben S <ogham@bsago.me> | 2015-05-16 21:02:28 +0100 |
commit | 50442a0bfeb3b5b2f5a2d2700546b81621f9850f (patch) | |
tree | fafd744194caf6548bc9b617b786011cba925853 /src/options.rs | |
parent | 8e7efed3f5ca66b0a92d13865f01d003bdadd918 (diff) |
Generify Table to be used in tests once again
Finally! The benefit of having all the field-rendering code (in details.rs) separate from the value-getting code (in file.rs) is that rendering them can be tested again.
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/options.rs b/src/options.rs index 9d8471d..00feec3 100644 --- a/src/options.rs +++ b/src/options.rs @@ -81,8 +81,8 @@ impl Options { } let matches = match opts.parse(args) { - Ok(m) => m, - Err(e) => return Err(Misfire::InvalidOptions(e)), + Ok(m) => m, + Err(e) => return Err(Misfire::InvalidOptions(e)), }; if matches.opt_present("help") { @@ -93,8 +93,8 @@ impl Options { } let sort_field = match matches.opt_str("sort") { - Some(word) => try!(SortField::from_word(word)), - None => SortField::Name, + Some(word) => try!(SortField::from_word(word)), + None => SortField::default(), }; let filter = FileFilter { @@ -166,6 +166,12 @@ pub enum SortField { ModifiedDate, AccessedDate, CreatedDate, } +impl Default for SortField { + fn default() -> SortField { + SortField::Name + } +} + impl SortField { /// Find which field to use based on a user-supplied word. |