Skip to content

Commit

Permalink
Fix literal flag not being recognized from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Akmadan23 committed Nov 13, 2023
1 parent 6f8e095 commit eac2ea9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/flags/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ impl Configurable<Self> for Literal {
/// Get a potential `Literal` value from [Cli].
///
/// If the "literal" argument is passed, this returns a `Literal` with value `true` in a
/// [Some]. Otherwise this returns `Literal` with value `false` in a [Some].
/// [Some]. Otherwise this returns [None].
fn from_cli(cli: &Cli) -> Option<Self> {
if cli.literal {
Some(Self(true))
} else {
Some(Self(false))
None
}
}

/// Get a potential `Literal` value from a [Config].
///
/// If the `Config::indicators` has value,
/// this returns its value as the value of the `Literal`, in a [Some].
/// Otherwise this returns `Literal` with value `false` in a [Some].
/// Otherwise this returns [None].
fn from_config(config: &Config) -> Option<Self> {
if let Some(value) = config.literal {

Check failure on line 32 in src/flags/literal.rs

View workflow job for this annotation

GitHub Actions / Style (ubuntu-latest)

manual implementation of `Option::map`

Check failure on line 32 in src/flags/literal.rs

View workflow job for this annotation

GitHub Actions / Style (windows-latest)

manual implementation of `Option::map`

Check failure on line 32 in src/flags/literal.rs

View workflow job for this annotation

GitHub Actions / Style (macos-latest)

manual implementation of `Option::map`
Some(Self(value))
} else {
Some(Self(false))
None
}
}
}
Expand All @@ -51,7 +51,7 @@ mod test {
fn test_from_cli_none() {
let argv = ["lsd"];
let cli = Cli::try_parse_from(argv).unwrap();
assert_eq!(Some(Literal(false)), Literal::from_cli(&cli));
assert_eq!(None, Literal::from_cli(&cli));
}

#[test]
Expand All @@ -63,10 +63,7 @@ mod test {

#[test]
fn test_from_config_none() {
assert_eq!(
Some(Literal(false)),
Literal::from_config(&Config::with_none())
);
assert_eq!(None, Literal::from_config(&Config::with_none()));
}

#[test]
Expand Down

0 comments on commit eac2ea9

Please sign in to comment.