From 0fc72391d3b0b49c701b051512f1b1eb3b4eb3df Mon Sep 17 00:00:00 2001 From: MartinFillon Date: Sat, 11 Nov 2023 16:46:53 +0100 Subject: [PATCH] feat(parser)!: Introduction of clap based parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This pr intoduce clap based parser. Please note that this is still a wip. Breaking Changes: -v no longer lists version. Version is no longer as exhaustive as before. Signed-off-by: Christina Sørensen --- src/options/filter.rs | 28 ++++++++++++++++++++++++++-- src/options/parser.rs | 2 -- src/options/view.rs | 12 ------------ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/options/filter.rs b/src/options/filter.rs index 724dbe934..1cff97364 100644 --- a/src/options/filter.rs +++ b/src/options/filter.rs @@ -195,7 +195,6 @@ impl GitIgnore { #[cfg(test)] mod tests { - use crate::options::parser::SortArgs; use super::*; use std::ffi::OsString; @@ -351,10 +350,22 @@ mod tests { ); } + #[test] + fn deduce_sort_field_name_mix_hidden_case() { + let opts = Opts { + sort: Some(OsString::from(".Name")), + ..Opts::default() + }; + assert_eq!( + SortField::deduce(&opts), + Ok(SortField::NameMixHidden(SortCase::ABCabc)) + ); + } + #[test] fn deduce_sort_field_size() { let opts = Opts { - sort: Some("size".into()), + sort: Some(OsString::from("size")), ..Opts::default() }; @@ -374,6 +385,19 @@ mod tests { ); } + #[test] + fn deduce_sort_field_extension_case() { + let opts = Opts { + sort: Some(OsString::from("Ext")), + ..Opts::default() + }; + + assert_eq!( + SortField::deduce(&opts), + Ok(SortField::Extension(SortCase::ABCabc)) + ); + } + #[test] fn deduce_sort_field_date() { let opts = Opts { diff --git a/src/options/parser.rs b/src/options/parser.rs index 09b45d56f..a543633fa 100644 --- a/src/options/parser.rs +++ b/src/options/parser.rs @@ -175,7 +175,6 @@ pub struct Opts { /// use stdin as the sole input #[arg(long = "stdin", action = clap::ArgAction::Count)] pub stdin: u8, - #[arg(short = 'O', long = "flags", action = clap::ArgAction::Count)] pub file_flags: u8, } @@ -187,7 +186,6 @@ pub enum ShowWhen { Auto, Never, } - #[derive(Clone, Debug, ValueEnum, PartialEq, Eq)] pub enum ColorScaleModeArgs { Fixed, diff --git a/src/options/view.rs b/src/options/view.rs index 4dcc7b1ee..11bd2ffde 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -978,18 +978,6 @@ mod tests { Ok(Mode::Grid(grid::Options { across: true })) ); } - // fn deduce_tree(matches: &Opts, vars: &V) -> Result { - // let details = details::Options { - // table: None, - // header: false, - // xattr: xattr::ENABLED && matches.extended > 0, - // secattr: xattr::ENABLED && matches.security_context > 0, - // mounts: matches.mounts > 0, - // color_scale: ColorScaleOptions::deduce(matches, vars)?, - // }; - // - // Ok(details) - // } #[test] fn deduce_details_options_tree() { let options = Opts {