2023-05-16 17:07:56 +00:00
|
|
|
use anyhow::Result;
|
|
|
|
use dialoguer::Input;
|
|
|
|
use dirs::home_dir;
|
2023-12-04 21:26:49 +00:00
|
|
|
use email::maildir::config::MaildirConfig;
|
2023-05-16 17:07:56 +00:00
|
|
|
|
2023-12-03 21:31:43 +00:00
|
|
|
use crate::{backend::config::BackendConfig, config::wizard::THEME};
|
2023-05-16 17:07:56 +00:00
|
|
|
|
|
|
|
pub(crate) fn configure() -> Result<BackendConfig> {
|
|
|
|
let mut config = MaildirConfig::default();
|
|
|
|
|
|
|
|
let mut input = Input::with_theme(&*THEME);
|
|
|
|
|
|
|
|
if let Some(home) = home_dir() {
|
|
|
|
input.default(home.join("Mail").display().to_string());
|
|
|
|
};
|
|
|
|
|
|
|
|
config.root_dir = input
|
|
|
|
.with_prompt("Maildir directory")
|
|
|
|
.interact_text()?
|
|
|
|
.into();
|
|
|
|
|
|
|
|
Ok(BackendConfig::Maildir(config))
|
|
|
|
}
|