Skip to content

Commit

Permalink
feat(parser)!: Introduction of clap based parser
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MartinFillon authored and PThorpe92 committed Feb 2, 2024
1 parent be337b7 commit 0fc7239
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
28 changes: 26 additions & 2 deletions src/options/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ impl GitIgnore {

#[cfg(test)]
mod tests {
use crate::options::parser::SortArgs;

use super::*;
use std::ffi::OsString;
Expand Down Expand Up @@ -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()
};

Expand All @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/options/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -187,7 +186,6 @@ pub enum ShowWhen {
Auto,
Never,
}

#[derive(Clone, Debug, ValueEnum, PartialEq, Eq)]
pub enum ColorScaleModeArgs {
Fixed,
Expand Down
12 changes: 0 additions & 12 deletions src/options/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,18 +978,6 @@ mod tests {
Ok(Mode::Grid(grid::Options { across: true }))
);
}
// fn deduce_tree<V: Vars>(matches: &Opts, vars: &V) -> Result<Self, OptionsError> {
// 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 {
Expand Down

0 comments on commit 0fc7239

Please sign in to comment.