summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzad <49314270+Akmadan23@users.noreply.github.com>2023-11-15 07:53:16 +0100
committerGitHub <noreply@github.com>2023-11-15 14:53:16 +0800
commit5d857b5bcc3d2b9fe4f18bc543b429f5e32ef170 (patch)
tree71acf3c599baf371c5ce45cfee50f27ddb6ba398
parent6f8e09524835cf15f5d5a9a7a1701e71dbe78f01 (diff)
Fix `literal` flag not being recognized from config file (#935)
The `literal` option was not correctly recognized from config file due to `Literal::from_cli` returning `Some(Literal(false))` instead of `None`, so `Literal::from_config` would never have been executed.
-rw-r--r--src/flags/literal.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/flags/literal.rs b/src/flags/literal.rs
index 0530f57..fdaf865 100644
--- a/src/flags/literal.rs
+++ b/src/flags/literal.rs
@@ -14,12 +14,12 @@ 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
}
}
@@ -27,13 +27,9 @@ impl Configurable<Self> for Literal {
///
/// 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 {
- Some(Self(value))
- } else {
- Some(Self(false))
- }
+ config.literal.map(Self)
}
}
@@ -51,7 +47,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]
@@ -63,10 +59,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]