himalaya/src/maildir/wizard.rs
Perma Alesheikh 5a0ff83a5e
replace anyhow and log with color_eyre and tracing
Since Himalaya is intended to be ran as a CLI in the terminal emulator
environment, their user experience could vastly improve with better and
more colorful error messages and logging.

This change will replace more minimal libraries for error-reporting/han-
dling with their more advanced counterparts.

Since these crates have tight integrations, this commit will change both
in one shot.

Also we have don't need env_logger any more. So I also have removed that
guy as well.

Signed-off-by: Perma Alesheikh <me@prma.dev>
2024-04-15 12:17:56 +02:00

24 lines
581 B
Rust

use color_eyre::Result;
use dialoguer::Input;
use dirs::home_dir;
use email::maildir::config::MaildirConfig;
use crate::{backend::config::BackendConfig, ui::THEME};
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))
}