Skip to content

Commit

Permalink
fix config and oauth2
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Dec 4, 2023
1 parent c54ada7 commit ea9c28b
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 182 deletions.
6 changes: 3 additions & 3 deletions src/backend/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ use crate::{config::wizard::THEME, maildir, sendmail};
use super::{config::BackendConfig, BackendKind};

const DEFAULT_BACKEND_KINDS: &[BackendKind] = &[
BackendKind::Maildir,
#[cfg(feature = "imap-backend")]
BackendKind::Imap,
BackendKind::Maildir,
#[cfg(feature = "notmuch-backend")]
BackendKind::Notmuch,
];

const SEND_MESSAGE_BACKEND_KINDS: &[BackendKind] = &[
BackendKind::Sendmail,
#[cfg(feature = "smtp-sender")]
BackendKind::Smtp,
BackendKind::Sendmail,
];

pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Option<BackendConfig>> {
Expand Down Expand Up @@ -52,7 +52,7 @@ pub(crate) async fn configure_sender(
email: &str,
) -> Result<Option<BackendConfig>> {
let kind = Select::with_theme(&*THEME)
.with_prompt("Default email backend")
.with_prompt("Backend for sending messages")
.items(SEND_MESSAGE_BACKEND_KINDS)
.default(0)
.interact_opt()?
Expand Down
16 changes: 12 additions & 4 deletions src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@ pub struct TomlConfig {
pub email_listing_datetime_fmt: Option<String>,
pub email_listing_datetime_local_tz: Option<bool>,
pub email_reading_headers: Option<Vec<String>>,
#[serde(default, with = "OptionEmailTextPlainFormatDef")]
#[serde(
default,
with = "OptionEmailTextPlainFormatDef",
skip_serializing_if = "Option::is_none"
)]
pub email_reading_format: Option<EmailTextPlainFormat>,
pub email_writing_headers: Option<Vec<String>>,
pub email_sending_save_copy: Option<bool>,
#[serde(default, with = "OptionEmailHooksDef")]
#[serde(
default,
with = "OptionEmailHooksDef",
skip_serializing_if = "Option::is_none"
)]
pub email_hooks: Option<EmailHooks>,

#[serde(flatten)]
Expand Down Expand Up @@ -78,7 +86,7 @@ impl TomlConfig {

let confirm = Confirm::new()
.with_prompt(wizard_prompt!(
"Would you like to create it with the wizard?"
"Would you like to create one with the wizard?"
))
.default(true)
.interact_opt()?
Expand All @@ -88,7 +96,7 @@ impl TomlConfig {
process::exit(0);
}

wizard::configure().await
wizard::configure(path).await
}

/// Read and parse the TOML configuration from default paths.
Expand Down
Loading

0 comments on commit ea9c28b

Please sign in to comment.