define SendmailConfig once

Reasons:
- Makes the declaration more concicse.
- Avoids the mutation.

Signed-off-by: Perma Alesheikh <me@prma.dev>
This commit is contained in:
Perma Alesheikh 2024-01-09 12:07:09 +03:30 committed by Clément DOUIN
parent 6fcdf7ea10
commit 8016ecb5a0
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72

View file

@ -5,13 +5,14 @@ use email::sendmail::config::SendmailConfig;
use crate::{backend::config::BackendConfig, ui::THEME}; use crate::{backend::config::BackendConfig, ui::THEME};
pub(crate) fn configure() -> Result<BackendConfig> { pub(crate) fn configure() -> Result<BackendConfig> {
let mut config = SendmailConfig::default(); let config = SendmailConfig {
cmd: Input::with_theme(&*THEME)
config.cmd = Input::with_theme(&*THEME) .with_prompt("Sendmail-compatible shell command to send emails")
.with_prompt("Sendmail-compatible shell command to send emails") .default(String::from("/usr/bin/msmtp"))
.default(String::from("/usr/bin/msmtp")) .interact()?
.interact()? .into(),
.into(); // ..Default::default() // in case any other field was added
};
Ok(BackendConfig::Sendmail(config)) Ok(BackendConfig::Sendmail(config))
} }