Skip to content

Commit

Permalink
fix(clippy): clippy lints were broken
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinFillon committed Sep 24, 2024
1 parent 9e6849d commit 54bda48
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 73 deletions.
73 changes: 1 addition & 72 deletions src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ use crate::output::{details, grid_details, Mode, View};
use crate::theme::Options as ThemeOptions;

mod dir_action;
mod error;
mod file_name;
mod filter;
#[rustfmt::skip] // this module becomes unreadable with rustfmt
Expand Down Expand Up @@ -167,75 +168,3 @@ impl Options {
})
}
}

/// The result of the `Options::parse` function.
///
/// NOTE: We disallow the `large_enum_variant` lint here, because we're not
/// overly concerned about variant fragmentation. We can do this because we are
/// reasonably sure that the error variant will be rare, and only on faulty
/// program execution and thus boxing the large variant will be a waste of
/// resources, but should we come to use it more, we should reconsider.
///
/// See <https://github.com/eza-community/eza/pull/437#issuecomment-1738470254>
#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
pub enum OptionsResult<'args> {
/// The options were parsed successfully.
Ok(Options, Vec<&'args OsStr>),

/// There was an error parsing the arguments.
InvalidOptions(OptionsError),

/// One of the arguments was `--help`, so display help.
Help(HelpString),

/// One of the arguments was `--version`, so display the version number.
Version(VersionString),
}

#[cfg(test)]
pub mod test {
use crate::options::parser::{Arg, MatchedFlags};
use std::ffi::OsStr;

#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum Strictnesses {
Last,
Complain,
Both,
}

/// This function gets used by the other testing modules.
/// It can run with one or both strictness values: if told to run with
/// both, then both should resolve to the same result.
///
/// It returns a vector with one or two elements in.
/// These elements can then be tested with `assert_eq` or what have you.
pub fn parse_for_test<T, F>(
inputs: &[&str],
args: &'static [&'static Arg],
strictnesses: Strictnesses,
get: F,
) -> Vec<T>
where
F: Fn(&MatchedFlags<'_>) -> T,
{
use self::Strictnesses::*;
use crate::options::parser::{Args, Strictness};

let bits = inputs.iter().map(OsStr::new).collect::<Vec<_>>();
let mut result = Vec::new();

if strictnesses == Last || strictnesses == Both {
let results = Args(args).parse(bits.clone(), Strictness::UseLastArguments);
result.push(get(&results.unwrap().flags));
}

if strictnesses == Complain || strictnesses == Both {
let results = Args(args).parse(bits, Strictness::ComplainAboutRedundantArguments);
result.push(get(&results.unwrap().flags));
}

result
}
}
2 changes: 1 addition & 1 deletion src/options/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::config::ThemeConfig;
impl Options {
pub fn deduce<V: Vars>(matches: &Opts, vars: &V) -> Self {
let use_colours = UseColours::deduce(matches, vars);
let colour_scale = ColorScaleOptions::deduce(matches, vars)?;
let colour_scale = ColorScaleOptions::deduce(matches, vars);
let theme_config = ThemeConfig::deduce(vars);

let definitions = if use_colours == UseColours::Never {
Expand Down

0 comments on commit 54bda48

Please sign in to comment.