cli: config get: break method chaining for ease of error type migration

.get_value() doesn't do type casting, so a Type error wouldn't occur.
This commit is contained in:
Yuya Nishihara 2024-12-01 13:32:27 +09:00
parent ba739b2f76
commit c3a8fb9f37

View file

@ -47,11 +47,8 @@ pub fn cmd_config_get(
command: &CommandHelper,
args: &ConfigGetArgs,
) -> Result<(), CommandError> {
let value = command
.settings()
.get_value(&args.name)
.and_then(|value| value.into_string())
.map_err(|err| match err {
let value = command.settings().get_value(&args.name)?;
let stringified = value.into_string().map_err(|err| match err {
ConfigError::Type {
origin,
unexpected,
@ -75,6 +72,6 @@ pub fn cmd_config_get(
}
err => err.into(),
})?;
writeln!(ui.stdout(), "{value}")?;
writeln!(ui.stdout(), "{stringified}")?;
Ok(())
}