From f5e8984035bc34e98faca0cb4da071cb378b3ede Mon Sep 17 00:00:00 2001 From: MartinFillon Date: Fri, 8 Sep 2023 20:16:33 +0200 Subject: [PATCH] feat(Parser): finished help argument and added a default to opts --- src/options/dir_action.rs | 69 ++--------------- src/options/file_name.rs | 61 +-------------- src/options/help.rs | 4 +- src/options/parser.rs | 102 +++++++++++++++++++++++- src/options/theme.rs | 158 ++++++-------------------------------- src/options/view.rs | 91 +++++----------------- 6 files changed, 156 insertions(+), 329 deletions(-) diff --git a/src/options/dir_action.rs b/src/options/dir_action.rs index c9b5e8b4c..ca9ea88fe 100644 --- a/src/options/dir_action.rs +++ b/src/options/dir_action.rs @@ -66,63 +66,10 @@ impl RecurseOptions { mod test { use super::*; - const DEFAULT: Opts = Opts { - paths: vec![], - all: 0, - long: 0, - git: 0, - oneline: 0, - recurse: 0, - list_dirs: 0, - tree: 0, - level: None, - reverse: 0, - sort: None, - ignore_glob: None, - git_ignore: 0, - dirs_first: 0, - only_dirs: 0, - binary: 0, - bytes: 0, - group: 0, - numeric: 0, - grid: 0, - across: 0, - classify: 0, - dereference: 0, - width: None, - color: None, - color_scale: 0, - almost_all: 0, - header: 0, - icons: 0, - inode: 0, - git_repos: 0, - git_repos_no_status: 0, - links: 0, - modified: 0, - created: 0, - accessed: 0, - changed: 0, - blocksize: 0, - time: None, - time_style: None, - no_filesize: 0, - no_icons: 0, - no_permissions: 0, - no_time: 0, - no_user: 0, - extended: 0, - hyperlink: 0, - octal: 0, - security_context: 0, - help: Some(false), - }; - #[test] fn deduces_list() { let matches = Opts { - ..DEFAULT + ..Opts::default() }; assert_eq!(DirAction::deduce(&matches, false, false).unwrap(), DirAction::List); @@ -132,7 +79,7 @@ mod test { fn deduce_recurse() { let matches = Opts { recurse: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(DirAction::deduce(&matches, false, false).unwrap(), DirAction::Recurse(RecurseOptions { tree: false, @@ -144,7 +91,7 @@ mod test { fn deduce_recurse_tree() { let matches = Opts { tree: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(DirAction::deduce(&matches, true, false).unwrap(), DirAction::Recurse(RecurseOptions { tree: true, @@ -156,7 +103,7 @@ mod test { fn deduce_as_file() { let matches = Opts { list_dirs: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(DirAction::deduce(&matches, false, false).unwrap(), DirAction::AsFile); } @@ -165,7 +112,7 @@ mod test { fn deduce_strict_unuseful_level() { let matches = Opts { level: Some(2), - ..DEFAULT + ..Opts::default() }; assert!(DirAction::deduce(&matches, false, true).is_err()); @@ -176,7 +123,7 @@ mod test { let matches = Opts { recurse: 1, list_dirs: 1, - ..DEFAULT + ..Opts::default() }; assert!(DirAction::deduce(&matches, false, true).is_err()); @@ -187,7 +134,7 @@ mod test { let matches = Opts { tree: 1, list_dirs: 1, - ..DEFAULT + ..Opts::default() }; assert!(DirAction::deduce(&matches, false, true).is_err()); @@ -199,7 +146,7 @@ mod test { recurse: 1, tree: 1, level: Some(2), - ..DEFAULT + ..Opts::default() }; assert_eq!(DirAction::deduce(&matches, true, false).unwrap(), DirAction::Recurse(RecurseOptions { diff --git a/src/options/file_name.rs b/src/options/file_name.rs index d82688f02..7908168d5 100644 --- a/src/options/file_name.rs +++ b/src/options/file_name.rs @@ -59,62 +59,9 @@ impl EmbedHyperlinks { mod test { use super::*; - const DEFAULT: Opts = Opts { - paths: vec![], - all: 0, - long: 0, - git: 0, - oneline: 0, - recurse: 0, - list_dirs: 0, - tree: 0, - level: None, - reverse: 0, - sort: None, - ignore_glob: None, - git_ignore: 0, - dirs_first: 0, - only_dirs: 0, - binary: 0, - bytes: 0, - group: 0, - numeric: 0, - grid: 0, - across: 0, - classify: 0, - dereference: 0, - width: None, - color: None, - color_scale: 0, - almost_all: 0, - header: 0, - icons: 0, - inode: 0, - git_repos: 0, - git_repos_no_status: 0, - links: 0, - modified: 0, - created: 0, - accessed: 0, - changed: 0, - blocksize: 0, - time: None, - time_style: None, - no_filesize: 0, - no_icons: 0, - no_permissions: 0, - no_time: 0, - no_user: 0, - extended: 0, - hyperlink: 0, - octal: 0, - security_context: 0, - help: Some(false), - }; - #[test] fn deduce_hyperlinks() { - assert_eq!(EmbedHyperlinks::deduce(&DEFAULT), EmbedHyperlinks::Off); + assert_eq!(EmbedHyperlinks::deduce(&Opts::default()), EmbedHyperlinks::Off); } #[test] @@ -122,7 +69,7 @@ mod test { let matches = Opts { hyperlink: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(EmbedHyperlinks::deduce(&matches), EmbedHyperlinks::On); @@ -132,7 +79,7 @@ mod test { fn deduce_classify() { let matches = Opts { classify: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(Classify::deduce(&matches), Classify::AddFileIndicators); @@ -141,7 +88,7 @@ mod test { #[test] fn deduce_classify_no_classify() { let matches = Opts { - ..DEFAULT + ..Opts::default() }; assert_eq!(Classify::deduce(&matches), Classify::JustFilenames); diff --git a/src/options/help.rs b/src/options/help.rs index e0ab7128d..1b838fc0b 100644 --- a/src/options/help.rs +++ b/src/options/help.rs @@ -27,7 +27,7 @@ // FILTERING AND SORTING OPTIONS // -a, --all show hidden and 'dot' files -// -d, --list-dirs list directories as files; don't list their contents +// -d, display entries as hyperlinks--list-dirs list directories as files; don't list their contents // -L, --level DEPTH limit the depth of recursion // -r, --reverse reverse the sort order // -s, --sort SORT_FIELD which field to sort by @@ -56,7 +56,7 @@ // -t, --time FIELD which timestamp field to list (modified, accessed, created) // -u, --accessed use the accessed timestamp field // -U, --created use the created timestamp field -// --changed use the changed timestamp field +// --change-dd use the changed timestamp field // --time-style how to format timestamps (default, iso, long-iso, full-iso, relative) // --no-permissions suppress the permissions field // -o, --octal-permissions list each file's permission in octal format diff --git a/src/options/parser.rs b/src/options/parser.rs index 744966122..1967f0b1a 100644 --- a/src/options/parser.rs +++ b/src/options/parser.rs @@ -1,7 +1,7 @@ pub use clap::Parser; use std::ffi::OsString; -#[derive(Parser)] +#[derive(Parser, Default)] #[command(author, version, about, long_about = None)] // Read from `Cargo.toml` #[clap(disable_help_flag = true)] pub struct Opts { @@ -18,89 +18,130 @@ pub struct Opts { /// Display one entry per line. #[arg(short = '1', long, action = clap::ArgAction::Count)] pub oneline: u8, - /// + ///recurse into directories as a tree. #[arg(short = 'T', long, action = clap::ArgAction::Count)] pub tree: u8, + /// display entries as a grid (default). #[arg(short = 'G', long, action = clap::ArgAction::Count)] pub grid: u8, + /// sort the grid across, rather than downwards. #[arg(short = 'x', long, action = clap::ArgAction::Count)] pub across: u8, + /// recurse into directories. #[arg(short = 'R', long, action = clap::ArgAction::Count)] pub recurse: u8, + /// display type indicator by file names. #[arg(short = 'F', long, action = clap::ArgAction::Count)] pub classify: u8, + /// #[arg(short = 'X', long, action = clap::ArgAction::Count)] pub dereference: u8, + /// set screen width in columns. #[arg(short = 'w', long)] pub width: Option, + /// when to use terminal colours (always, auto, never). #[arg(long)] pub color: Option, + /// highlight levels of file sizes distinctly. #[arg(long, action = clap::ArgAction::Count)] pub color_scale: u8, + /// #[arg(short = 'A', long, action = clap::ArgAction::Count)] pub almost_all: u8, + /// list directories as files; don't list their contents. #[arg(short = 'd', long, action = clap::ArgAction::Count)] pub list_dirs: u8, + /// limit the depth of recursion. #[arg(short = 'L', long)] pub level: Option, + /// reverse the sort order. #[arg(short = 'r', long, action = clap::ArgAction::Count)] pub reverse: u8, + /// which field to sort by. #[arg(short = 's', long)] pub sort: Option, + /// glob patterns (pipe-separated) of files to ignore. #[arg(short = 'I', long)] pub ignore_glob: Option, + /// ignore files mentioned in '.gitignore'. #[arg(long = "git-ignore", action = clap::ArgAction::Count)] pub git_ignore: u8, + /// list directories before other files. #[arg(long = "group-directories-first", action = clap::ArgAction::Count)] pub dirs_first: u8, + /// list only directories. #[arg(short = 'D', long = "only-dirs", action = clap::ArgAction::Count)] pub only_dirs: u8, + /// list file sizes with binary prefixes. #[arg(short = 'b', long, action = clap::ArgAction::Count)] pub binary: u8, + /// list file sizes in bytes, without any prefixes. #[arg(short = 'B', long, action = clap::ArgAction::Count)] pub bytes: u8, + /// list each file's group. #[arg(short = 'g', long, action = clap::ArgAction::Count)] pub group: u8, + /// list numeric user and group IDs. #[arg(short = 'n', long, action = clap::ArgAction::Count)] pub numeric: u8, + /// add a header row to each column. #[arg(short = 'h', long, action = clap::ArgAction::Count)] pub header: u8, + /// display icons #[arg(long, action = clap::ArgAction::Count)] pub icons: u8, + /// list each file's inode number. #[arg(short = 'i', long, action = clap::ArgAction::Count)] pub inode: u8, + /// list each file's number of hard links. #[arg(short = 'H', long, action = clap::ArgAction::Count)] pub links: u8, + /// use the modified timestamp field. #[arg(short = 'm', long, action = clap::ArgAction::Count)] pub modified: u8, + /// use the changed timestamp field. #[arg(long, action = clap::ArgAction::Count)] pub changed: u8, + /// show size of allocated file system blocks. #[arg(short = 'S', long, action = clap::ArgAction::Count)] pub blocksize: u8, + /// which timestamp field to list (modified, accessed, created). #[arg(short = 't', long)] pub time: Option, + /// use the accessed timestamp field. #[arg(short = 'u', long, action = clap::ArgAction::Count)] pub accessed: u8, + /// use the created timestamp field. #[arg(short = 'U', long, action = clap::ArgAction::Count)] pub created: u8, + /// how to format timestamps (default, iso, long-iso, full-iso, relative). #[arg(long = "time-style")] pub time_style: Option, + /// display entries as hyperlinks. #[arg(long, action = clap::ArgAction::Count)] pub hyperlink: u8, + /// supress the permissions field. #[arg(long = "no-permissions", action = clap::ArgAction::Count)] pub no_permissions: u8, + /// suppress the filesize field. #[arg(long = "no-filesize", action = clap::ArgAction::Count)] pub no_filesize: u8, + /// suppress the user field. #[arg(long = "no-user", action = clap::ArgAction::Count)] pub no_user: u8, + /// suppress the time field. #[arg(long = "no-time", action = clap::ArgAction::Count)] pub no_time: u8, + /// don't display icons (always override --icons). #[arg(long = "no-icons", action = clap::ArgAction::Count)] pub no_icons: u8, + /// list root of git-tree status. #[arg(long = "git-repos", action = clap::ArgAction::Count)] pub git_repos: u8, + /// #[arg(long = "git-repos-no-status", action = clap::ArgAction::Count)] pub git_repos_no_status: u8, + /// list each file's permission in octal format. #[arg(short = 'o', long, action = clap::ArgAction::Count)] pub octal: u8, /// Display the number of hard links to file. @@ -113,3 +154,60 @@ pub struct Opts { #[arg(short ='?', long, action = clap::ArgAction::Help)] pub help: Option, } + +impl Opts { + pub fn default() -> Opts { + Opts { + paths: vec![], + all: 0, + long: 0, + git: 0, + oneline: 0, + recurse: 0, + list_dirs: 0, + tree: 0, + level: None, + reverse: 0, + sort: None, + ignore_glob: None, + git_ignore: 0, + dirs_first: 0, + only_dirs: 0, + binary: 0, + bytes: 0, + group: 0, + numeric: 0, + grid: 0, + across: 0, + classify: 0, + dereference: 0, + width: None, + color: None, + color_scale: 0, + almost_all: 0, + header: 0, + icons: 0, + inode: 0, + git_repos: 0, + git_repos_no_status: 0, + links: 0, + modified: 0, + created: 0, + accessed: 0, + changed: 0, + blocksize: 0, + time: None, + time_style: None, + no_filesize: 0, + no_icons: 0, + no_permissions: 0, + no_time: 0, + no_user: 0, + extended: 0, + hyperlink: 0, + octal: 0, + security_context: 0, + help: Some(false), + } + } +} diff --git a/src/options/theme.rs b/src/options/theme.rs index 948256e96..5e2dfa0b2 100644 --- a/src/options/theme.rs +++ b/src/options/theme.rs @@ -65,138 +65,26 @@ impl Definitions { } -// #[cfg(test)] -// mod terminal_test { -// use super::*; -// use std::ffi::OsString; -// use crate::options::flags; -// use crate::options::parser::{Flag, Arg}; - -// use crate::options::test::parse_for_test; -// use crate::options::test::Strictnesses::*; - -// static TEST_ARGS: &[&Arg] = &[ &flags::COLOR, &flags::COLOUR, -// &flags::COLOR_SCALE, &flags::COLOUR_SCALE, ]; - -// macro_rules! test { -// ($name:ident: $type:ident <- $inputs:expr; $stricts:expr => $result:expr) => { -// #[test] -// fn $name() { -// for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) { -// assert_eq!(result, $result); -// } -// } -// }; - -// ($name:ident: $type:ident <- $inputs:expr, $env:expr; $stricts:expr => $result:expr) => { -// #[test] -// fn $name() { -// let env = $env; -// for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf, &env)) { -// assert_eq!(result, $result); -// } -// } -// }; - -// ($name:ident: $type:ident <- $inputs:expr; $stricts:expr => err $result:expr) => { -// #[test] -// fn $name() { -// for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) { -// assert_eq!(result.unwrap_err(), $result); -// } -// } -// }; - -// ($name:ident: $type:ident <- $inputs:expr, $env:expr; $stricts:expr => err $result:expr) => { -// #[test] -// fn $name() { -// let env = $env; -// for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf, &env)) { -// assert_eq!(result.unwrap_err(), $result); -// } -// } -// }; -// } - -// struct MockVars { -// ls: &'static str, -// exa: &'static str, -// no_color: &'static str, -// } - -// impl MockVars { -// fn empty() -> MockVars { -// MockVars { -// ls: "", -// exa: "", -// no_color: "", -// } -// } -// fn with_no_color() -> MockVars { -// MockVars { -// ls: "", -// exa: "", -// no_color: "true", -// } -// } -// } - -// // Test impl that just returns the value it has. -// impl Vars for MockVars { -// fn get(&self, name: &'static str) -> Option { -// if name == vars::LS_COLORS && ! self.ls.is_empty() { -// Some(OsString::from(self.ls)) -// } -// else if name == vars::EXA_COLORS && ! self.exa.is_empty() { -// Some(OsString::from(self.exa)) -// } -// else if name == vars::NO_COLOR && ! self.no_color.is_empty() { -// Some(OsString::from(self.no_color)) -// } -// else { -// None -// } -// } -// } - - - -// // Default -// test!(empty: UseColours <- [], MockVars::empty(); Both => Ok(UseColours::Automatic)); -// test!(empty_with_no_color: UseColours <- [], MockVars::with_no_color(); Both => Ok(UseColours::Never)); - -// // --colour -// test!(u_always: UseColours <- ["--colour=always"], MockVars::empty(); Both => Ok(UseColours::Always)); -// test!(u_auto: UseColours <- ["--colour", "auto"], MockVars::empty(); Both => Ok(UseColours::Automatic)); -// test!(u_never: UseColours <- ["--colour=never"], MockVars::empty(); Both => Ok(UseColours::Never)); - -// // --color -// test!(no_u_always: UseColours <- ["--color", "always"], MockVars::empty(); Both => Ok(UseColours::Always)); -// test!(no_u_auto: UseColours <- ["--color=auto"], MockVars::empty(); Both => Ok(UseColours::Automatic)); -// test!(no_u_never: UseColours <- ["--color", "never"], MockVars::empty(); Both => Ok(UseColours::Never)); - -// // Errors -// test!(no_u_error: UseColours <- ["--color=upstream"], MockVars::empty(); Both => err OptionsError::BadArgument(&flags::COLOR, OsString::from("upstream"))); // the error is for --color -// test!(u_error: UseColours <- ["--colour=lovers"], MockVars::empty(); Both => err OptionsError::BadArgument(&flags::COLOR, OsString::from("lovers"))); // and so is this one! - -// // Overriding -// test!(overridden_1: UseColours <- ["--colour=auto", "--colour=never"], MockVars::empty(); Last => Ok(UseColours::Never)); -// test!(overridden_2: UseColours <- ["--color=auto", "--colour=never"], MockVars::empty(); Last => Ok(UseColours::Never)); -// test!(overridden_3: UseColours <- ["--colour=auto", "--color=never"], MockVars::empty(); Last => Ok(UseColours::Never)); -// test!(overridden_4: UseColours <- ["--color=auto", "--color=never"], MockVars::empty(); Last => Ok(UseColours::Never)); - -// test!(overridden_5: UseColours <- ["--colour=auto", "--colour=never"], MockVars::empty(); Complain => err OptionsError::Duplicate(Flag::Long("colour"), Flag::Long("colour"))); -// test!(overridden_6: UseColours <- ["--color=auto", "--colour=never"], MockVars::empty(); Complain => err OptionsError::Duplicate(Flag::Long("color"), Flag::Long("colour"))); -// test!(overridden_7: UseColours <- ["--colour=auto", "--color=never"], MockVars::empty(); Complain => err OptionsError::Duplicate(Flag::Long("colour"), Flag::Long("color"))); -// test!(overridden_8: UseColours <- ["--color=auto", "--color=never"], MockVars::empty(); Complain => err OptionsError::Duplicate(Flag::Long("color"), Flag::Long("color"))); - -// test!(scale_1: ColourScale <- ["--color-scale", "--colour-scale"]; Last => Ok(ColourScale::Gradient)); -// test!(scale_2: ColourScale <- ["--color-scale", ]; Last => Ok(ColourScale::Gradient)); -// test!(scale_3: ColourScale <- [ "--colour-scale"]; Last => Ok(ColourScale::Gradient)); -// test!(scale_4: ColourScale <- [ ]; Last => Ok(ColourScale::Fixed)); - -// test!(scale_5: ColourScale <- ["--color-scale", "--colour-scale"]; Complain => err OptionsError::Duplicate(Flag::Long("color-scale"), Flag::Long("colour-scale"))); -// test!(scale_6: ColourScale <- ["--color-scale", ]; Complain => Ok(ColourScale::Gradient)); -// test!(scale_7: ColourScale <- [ "--colour-scale"]; Complain => Ok(ColourScale::Gradient)); -// test!(scale_8: ColourScale <- [ ]; Complain => Ok(ColourScale::Fixed)); -// } +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn deduce_colour_scale() { + let matches = Opts { + ..Opts::default() + }; + + assert_eq!(ColourScale::deduce(&matches), ColourScale::Fixed); + } + + #[test] + fn deduce_colour_scale_on() { + let matches = Opts { + color_scale: 1, + ..Opts::default() + }; + + assert_eq!(ColourScale::deduce(&matches), ColourScale::Gradient); + } +} diff --git a/src/options/view.rs b/src/options/view.rs index 9dd528d75..b2942ee53 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -359,63 +359,10 @@ mod test { use super::*; use std::ffi::OsString; - const DEFAULT: Opts = Opts { - paths: vec![], - all: 0, - long: 0, - git: 0, - oneline: 0, - recurse: 0, - list_dirs: 0, - tree: 0, - level: None, - reverse: 0, - sort: None, - ignore_glob: None, - git_ignore: 0, - dirs_first: 0, - only_dirs: 0, - binary: 0, - bytes: 0, - group: 0, - numeric: 0, - grid: 0, - across: 0, - classify: 0, - dereference: 0, - width: None, - color: None, - color_scale: 0, - almost_all: 0, - header: 0, - icons: 0, - inode: 0, - git_repos: 0, - git_repos_no_status: 0, - links: 0, - modified: 0, - created: 0, - accessed: 0, - changed: 0, - blocksize: 0, - time: None, - time_style: None, - no_filesize: 0, - no_icons: 0, - no_permissions: 0, - no_time: 0, - no_user: 0, - extended: 0, - hyperlink: 0, - octal: 0, - security_context: 0, - help: Some(false), - }; - #[test] fn deduce_time_type() { let matches = Opts { - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes::default()); @@ -425,7 +372,7 @@ mod test { fn deduce_time_type_modified() { let matches = Opts { modified: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { modified: true, ..TimeTypes::default() }); @@ -435,7 +382,7 @@ mod test { fn deduce_time_type_changed() { let matches = Opts { changed: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { changed: true, modified: false, ..TimeTypes::default() }); @@ -445,7 +392,7 @@ mod test { fn deduce_time_type_accessed() { let matches = Opts { accessed: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { accessed: true, modified: false,..TimeTypes::default() }); @@ -455,7 +402,7 @@ mod test { fn deduce_time_type_created() { let matches = Opts { created: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { created: true, modified: false, ..TimeTypes::default() }); @@ -465,7 +412,7 @@ mod test { fn deduce_time_type_mod_string() { let matches = Opts { time: Some(OsString::from("mod")), - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { modified: true, ..TimeTypes::default() }); @@ -475,7 +422,7 @@ mod test { fn deduce_time_type_ch_string() { let matches = Opts { time: Some(OsString::from("ch")), - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { changed: true, modified: false, ..TimeTypes::default() }); @@ -485,7 +432,7 @@ mod test { fn deduce_time_type_acc_string() { let matches = Opts { time: Some(OsString::from("acc")), - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { accessed: true, modified: false, ..TimeTypes::default() }); @@ -495,7 +442,7 @@ mod test { fn deduce_time_type_cr_string() { let matches = Opts { time: Some(OsString::from("cr")), - ..DEFAULT + ..Opts::default() }; assert_eq!(TimeTypes::deduce(&matches).unwrap(), TimeTypes { created: true, modified: false, ..TimeTypes::default() }); @@ -506,7 +453,7 @@ mod test { let matches = Opts { time: Some(OsString::from("mod")), modified: 1, - ..DEFAULT + ..Opts::default() }; assert!(TimeTypes::deduce(&matches).is_err()); @@ -517,7 +464,7 @@ mod test { let matches = Opts { time: Some(OsString::from("ch")), changed: 1, - ..DEFAULT + ..Opts::default() }; assert!(TimeTypes::deduce(&matches).is_err()); @@ -528,7 +475,7 @@ mod test { let matches = Opts { time: Some(OsString::from("acc")), accessed: 1, - ..DEFAULT + ..Opts::default() }; assert!(TimeTypes::deduce(&matches).is_err()); @@ -539,7 +486,7 @@ mod test { let matches = Opts { time: Some(OsString::from("cr")), created: 1, - ..DEFAULT + ..Opts::default() }; assert!(TimeTypes::deduce(&matches).is_err()); @@ -548,7 +495,7 @@ mod test { #[test] fn deduce_user_format() { let matches = Opts { - ..DEFAULT + ..Opts::default() }; assert_eq!(UserFormat::deduce(&matches), UserFormat::Name); @@ -558,7 +505,7 @@ mod test { fn deduce_user_format_numeric() { let matches = Opts { numeric: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(UserFormat::deduce(&matches), UserFormat::Numeric); @@ -567,7 +514,7 @@ mod test { #[test] fn deduce_size_format() { let matches = Opts { - ..DEFAULT + ..Opts::default() }; assert_eq!(SizeFormat::deduce(&matches), SizeFormat::DecimalBytes); @@ -577,7 +524,7 @@ mod test { fn deduce_size_format_binary() { let matches = Opts { binary: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(SizeFormat::deduce(&matches), SizeFormat::BinaryBytes); @@ -587,7 +534,7 @@ mod test { fn deduce_size_format_bytes() { let matches = Opts { bytes: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(SizeFormat::deduce(&matches), SizeFormat::JustBytes); @@ -597,7 +544,7 @@ mod test { fn deduce_dtails_tree() { let matches = Opts { tree: 1, - ..DEFAULT + ..Opts::default() }; assert_eq!(details::Options::deduce_tree(&matches), details::Options {