apply pr #461 due to conflicts, bump pimalaya crates

This commit is contained in:
Clément DOUIN
2023-12-10 22:01:49 +01:00
parent 203ed2f917
commit 8e05be7f77
10 changed files with 980 additions and 379 deletions
+20 -1
View File
@@ -1,11 +1,12 @@
use anyhow::{bail, Result};
use dialoguer::Input;
use dialoguer::{Confirm, Input};
use email_address::EmailAddress;
use crate::{
backend::{self, config::BackendConfig, BackendKind},
config::wizard::THEME,
message::config::{MessageConfig, MessageSendConfig},
wizard_prompt,
};
use super::TomlAccountConfig;
@@ -35,6 +36,14 @@ pub(crate) async fn configure() -> Result<Option<(String, TomlAccountConfig)>> {
.interact()?,
);
config.downloads_dir = Some(
Input::with_theme(&*THEME)
.with_prompt("Downloads directory")
.default(String::from("~/Downloads"))
.interact()?
.into(),
);
match backend::wizard::configure(&account_name, &config.email).await? {
Some(BackendConfig::Maildir(mdir_config)) => {
config.maildir = Some(mdir_config);
@@ -78,5 +87,15 @@ pub(crate) async fn configure() -> Result<Option<(String, TomlAccountConfig)>> {
_ => (),
};
config.sync = Some(
Confirm::new()
.with_prompt(wizard_prompt!(
"Do you need an offline access to your account?"
))
.default(false)
.interact_opt()?
.unwrap_or_default(),
);
Ok(Some((account_name, config)))
}
+2 -2
View File
@@ -1,7 +1,7 @@
use anyhow::Result;
use dialoguer::{theme::ColorfulTheme, Confirm, Input, Password, Select};
use once_cell::sync::Lazy;
use shellexpand_utils::shellexpand_path;
use shellexpand_utils::expand;
use std::{fs, io, path::PathBuf, process};
use toml_edit::{Document, Item};
@@ -94,7 +94,7 @@ pub(crate) async fn configure(path: PathBuf) -> Result<TomlConfig> {
))
.default(path.to_string_lossy().to_string())
.interact()?;
let path = shellexpand_path(&path);
let path = expand::path(&path);
println!("Writing the configuration to {path:?}");
@@ -1,7 +1,7 @@
use anyhow::{Context, Result};
use clap::Parser;
use log::info;
use std::fs;
use std::{fs, path::PathBuf};
use uuid::Uuid;
use crate::{
@@ -67,6 +67,8 @@ impl AttachmentDownloadCommand {
for attachment in attachments {
let filename = attachment
.filename
.map(PathBuf::from)
.and_then(|f| f.file_name().map(|f| f.to_string_lossy().to_string()))
.unwrap_or_else(|| Uuid::new_v4().to_string());
let filepath = account_config.download_fpath(&filename)?;
printer.print_log(format!("Downloading {:?}", filepath))?;
+2 -3
View File
@@ -1,8 +1,7 @@
use anyhow::Result;
use atty::Stream;
use clap::Parser;
use log::info;
use std::io::{self, BufRead};
use std::io::{self, BufRead, IsTerminal};
use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag,
@@ -40,7 +39,7 @@ impl MessageSaveCommand {
config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let is_tty = atty::is(Stream::Stdin);
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
let msg = if is_tty || is_json {
self.message.raw()
+2 -3
View File
@@ -1,9 +1,8 @@
use anyhow::Result;
use atty::Stream;
use clap::Parser;
use email::flag::Flag;
use log::info;
use std::io::{self, BufRead};
use std::io::{self, BufRead, IsTerminal};
use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag,
@@ -38,7 +37,7 @@ impl MessageSendCommand {
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let folder = account_config.sent_folder_alias()?;
let is_tty = atty::is(Stream::Stdin);
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
let msg = if is_tty || is_json {
self.message.raw()
+2 -3
View File
@@ -1,9 +1,8 @@
use anyhow::Result;
use atty::Stream;
use clap::Parser;
use log::info;
use mml::MmlCompilerBuilder;
use std::io::{self, BufRead};
use std::io::{self, BufRead, IsTerminal};
use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag,
@@ -44,7 +43,7 @@ impl TemplateSaveCommand {
config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), false).await?;
let is_tty = atty::is(Stream::Stdin);
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
let tpl = if is_tty || is_json {
self.template.raw()
+2 -3
View File
@@ -1,10 +1,9 @@
use anyhow::Result;
use atty::Stream;
use clap::Parser;
use email::flag::Flag;
use log::info;
use mml::MmlCompilerBuilder;
use std::io::{self, BufRead};
use std::io::{self, BufRead, IsTerminal};
use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag,
@@ -41,7 +40,7 @@ impl TemplateSendCommand {
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let folder = account_config.sent_folder_alias()?;
let is_tty = atty::is(Stream::Stdin);
let is_tty = io::stdin().is_terminal();
let is_json = printer.is_json();
let tpl = if is_tty || is_json {
self.template.raw()
+6 -3
View File
@@ -1,8 +1,11 @@
use anyhow::{anyhow, Error, Result};
use atty::Stream;
use clap::ValueEnum;
use serde::Serialize;
use std::{fmt, str::FromStr};
use std::{
fmt,
io::{self, IsTerminal},
str::FromStr,
};
use termcolor::ColorChoice;
/// Represents the available output formats.
@@ -78,7 +81,7 @@ impl From<ColorFmt> for ColorChoice {
ColorFmt::Always => Self::Always,
ColorFmt::Ansi => Self::AlwaysAnsi,
ColorFmt::Auto => {
if atty::is(Stream::Stdout) {
if io::stdout().is_terminal() {
// Otherwise let's `termcolor` decide by
// inspecting the environment. From the [doc]:
//