Skip to content

Commit

Permalink
fix: merge conflict issues
Browse files Browse the repository at this point in the history
  • Loading branch information
PThorpe92 committed Feb 2, 2024
1 parent 2f16723 commit be337b7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 49 deletions.
9 changes: 4 additions & 5 deletions src/options/file_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ impl EmbedHyperlinks {

#[cfg(test)]
mod tests {
use clap::builder::OsStr;

use super::*;
use crate::options::parser::ShowWhen;
use crate::options::vars::MockVars;
use clap::ValueEnum;
use std::ffi::OsString;
Expand Down Expand Up @@ -217,7 +216,7 @@ mod tests {
#[test]
fn deduce_show_icons_auto() {
let options = Opts {
icons: Some(OsStr::from("auto").into()),
icons: Some(ShowWhen::from_str("auto", false).unwrap()),
..Opts::default()
};

Expand All @@ -243,7 +242,7 @@ mod tests {
#[test]
fn deduce_show_icons_width() {
let options = Opts {
icons: Some(OsStr::from("auto").into()),
icons: Some(ShowWhen::from_str("", false).unwrap()),
..Opts::default()
};

Expand All @@ -262,7 +261,7 @@ mod tests {
#[test]
fn deduce_show_icons_width_error() {
let options = Opts {
icons: Some(OsStr::from("auto").into()),
icons: Some(ShowWhen::from_str("auto", false).unwrap()),
..Opts::default()
};

Expand Down
59 changes: 31 additions & 28 deletions src/options/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,36 @@ pub enum ShowWhen {
Auto,
Never,
}

#[derive(Clone, Debug, ValueEnum, PartialEq, Eq)]
pub enum ColorScaleModeArgs {
Fixed,
Gradient,
}

#[derive(Clone, Debug, ValueEnum, PartialEq, Eq)]
pub enum TimeStyleArgs {
Default,
Iso,
LongIso,
FullIso,
Relative,
}

#[derive(Clone, Debug, ValueEnum, PartialEq, Eq)]
pub enum SortArgs {
Name,
Size,
Time,
Extension,
Inode,
Version,
Created,
Accessed,
Modified,
Changed,
}

impl ValueEnum for ShowWhen {
fn value_variants<'a>() -> &'a [Self] {
&[Self::Always, Self::Auto, Self::Never]
Expand All @@ -202,6 +232,7 @@ impl ValueEnum for ShowWhen {

fn from_str(s: &str, _ignore_case: bool) -> Result<Self, String> {
match s.to_lowercase().as_str() {
"" => Ok(Self::Auto),
"always" => Ok(Self::Always),
"auto" | "automatic" => Ok(Self::Auto),
"never" => Ok(Self::Never),
Expand Down Expand Up @@ -294,34 +325,6 @@ impl Display for ColorScaleArgs {
}
}

#[derive(Clone, Debug, ValueEnum, PartialEq, Eq)]
pub enum ColorScaleModeArgs {
Fixed,
Gradient,
}
impl Display for ColorScaleModeArgs {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ColorScaleModeArgs::Fixed => write!(f, "fixed"),
ColorScaleModeArgs::Gradient => write!(f, "gradient"),
}
}
}

#[derive(Clone, Debug, ValueEnum, PartialEq, Eq)]
pub enum SortArgs {
Name,
Size,
Time,
Extension,
Inode,
Version,
Created,
Accessed,
Modified,
Changed,
}

impl From<clap::builder::OsStr> for SortArgs {
fn from(value: clap::builder::OsStr) -> Self {
match value.to_ascii_lowercase().to_str() {
Expand Down
34 changes: 18 additions & 16 deletions src/options/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,24 @@ pub struct MockVars {
pub icons: OsString,
pub time: OsString,
}

#[cfg(test)]
#[allow(dead_code)]
impl Default for MockVars {
fn default() -> Self {
Self {
columns: OsString::new(),
colors: OsString::new(),
no_colors: OsString::new(),
strict: OsString::new(),
grid_rows: OsString::new(),
debug: OsString::new(),
luminance: OsString::new(),
icon_spacing: OsString::new(),
icons: OsString::new(),
time: OsString::new(),
}
}
}
#[cfg(test)]
#[allow(dead_code)]
impl Vars for MockVars {
Expand Down Expand Up @@ -160,21 +177,6 @@ impl MockVars {
_ => (),
};
}

pub fn default() -> Self {
Self {
columns: OsString::new(),
colors: OsString::new(),
no_colors: OsString::new(),
strict: OsString::new(),
grid_rows: OsString::new(),
debug: OsString::new(),
luminance: OsString::new(),
icon_spacing: OsString::new(),
icons: OsString::new(),
time: OsString::new(),
}
}
}

#[cfg(test)]
Expand Down

0 comments on commit be337b7

Please sign in to comment.