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
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
10 changed files with 980 additions and 379 deletions

1129
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
[package] [package]
name = "himalaya" name = "himalaya"
description = "CLI to manage emails." description = "CLI to manage emails"
version = "0.9.0" version = "1.0.0-beta"
authors = ["soywod <clement.douin@posteo.net>"] authors = ["soywod <clement.douin@posteo.net>"]
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
@ -36,135 +36,45 @@ pgp-commands = ["pgp", "mml-lib/pgp-commands", "email-lib/pgp-commands"]
pgp-gpg = ["pgp", "mml-lib/pgp-gpg", "email-lib/pgp-gpg"] pgp-gpg = ["pgp", "mml-lib/pgp-gpg", "email-lib/pgp-gpg"]
pgp-native = ["pgp", "mml-lib/pgp-native", "email-lib/pgp-native"] pgp-native = ["pgp", "mml-lib/pgp-native", "email-lib/pgp-native"]
# dev dependencies [dev-dependencies]
async-trait = "0.1"
tempfile = "3.3"
[dev-dependencies.async-trait] [dependencies]
version = "0.1" anyhow = "1"
async-trait = "0.1"
[dev-dependencies.tempfile] chrono = "0.4.24"
version = "3.3" clap = { version = "4.4", features = ["derive"] }
clap_complete = "4.4"
# dependencies clap_mangen = "0.2"
console = "0.15.2"
[dependencies.anyhow] dialoguer = "0.10.2"
version = "1.0" dirs = "4.0"
email-lib = { version = "=0.16.0", default-features = false }
[dependencies.async-trait] email_address = "0.2.4"
version = "0.1" env_logger = "0.8"
erased-serde = "0.3"
[dependencies.atty] indicatif = "0.17"
version = "0.2" keyring-lib = "=0.2.0"
log = "0.4"
[dependencies.chrono] mail-builder = "0.3"
version = "0.4.24" md5 = "0.7.0"
mml-lib = { version = "=1.0.2", default-features = false }
[dependencies.clap] oauth-lib = "=0.1.0"
version = "4.4" once_cell = "1.16"
features = ["derive", "wrap_help"] process-lib = "=0.2.0"
secret-lib = "=0.2.0"
[dependencies.clap_complete] serde = { version = "1.0", features = ["derive"] }
version = "4.4" serde_json = "1.0"
shellexpand-utils = "=0.2.0"
[dependencies.clap_mangen] termcolor = "1.1"
version = "0.2" terminal_size = "0.1"
tokio = { version = "1.23", default-features = false, features = ["macros", "rt-multi-thread"] }
[dependencies.console] toml = "0.7.4"
version = "0.15.2" toml_edit = "0.19.8"
unicode-width = "0.1"
[dependencies.dialoguer] url = "2.2"
version = "0.10.2" uuid = { version = "0.8", features = ["v4"] }
[dependencies.dirs]
version = "4.0.0"
[dependencies.email_address]
version = "0.2.4"
[dependencies.env_logger]
version = "0.10"
[dependencies.erased-serde]
version = "0.3"
[dependencies.indicatif]
version = "0.17"
[dependencies.log]
version = "0.4"
[dependencies.md5]
version = "0.7.0"
[dependencies.once_cell]
version = "1.16.0"
[dependencies.email-lib]
# version = "=0.15.3"
default-features = false
path = "/home/soywod/sourcehut/pimalaya/email"
[dependencies.keyring-lib]
# version = "=0.1.0"
path = "/home/soywod/sourcehut/pimalaya/keyring"
[dependencies.mail-builder]
version = "0.3"
[dependencies.oauth-lib]
# version = "=0.1.0"
path = "/home/soywod/sourcehut/pimalaya/oauth"
[dependencies.process-lib]
# version = "=0.1.0"
path = "/home/soywod/sourcehut/pimalaya/process"
[dependencies.mml-lib]
# version = "=1.0.1"
default-features = false
features = ["compiler", "interpreter"]
path = "/home/soywod/sourcehut/pimalaya/mml"
[dependencies.secret-lib]
# version = "=0.1.0"
path = "/home/soywod/sourcehut/pimalaya/secret"
[dependencies.serde]
version = "1.0"
features = ["derive"]
[dependencies.serde_json]
version = "1.0"
[dependencies.shellexpand-utils]
# version = "=0.1.0"
path = "/home/soywod/sourcehut/pimalaya/shellexpand-utils"
[dependencies.termcolor]
version = "1.1"
[dependencies.terminal_size]
version = "0.1"
[dependencies.tokio]
version = "1.23"
default-features = false
features = ["macros", "rt-multi-thread"]
[dependencies.toml]
version = "0.7.4"
[dependencies.toml_edit]
version = "0.19.8"
[dependencies.unicode-width]
version = "0.1"
[dependencies.url]
version = "2.2"
[dependencies.uuid]
version = "0.8"
features = ["v4"]
[target.'cfg(target_env = "musl")'.dependencies.rusqlite] [target.'cfg(target_env = "musl")'.dependencies.rusqlite]
version = "0.29" version = "0.29"
@ -175,4 +85,4 @@ version = "0.29"
features = ["bundled"] features = ["bundled"]
[target.'cfg(not(windows))'.dependencies.coredump] [target.'cfg(not(windows))'.dependencies.coredump]
version = "=0.1.2" version = "=0.1.2"

View file

@ -1,11 +1,12 @@
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use dialoguer::Input; use dialoguer::{Confirm, Input};
use email_address::EmailAddress; use email_address::EmailAddress;
use crate::{ use crate::{
backend::{self, config::BackendConfig, BackendKind}, backend::{self, config::BackendConfig, BackendKind},
config::wizard::THEME, config::wizard::THEME,
message::config::{MessageConfig, MessageSendConfig}, message::config::{MessageConfig, MessageSendConfig},
wizard_prompt,
}; };
use super::TomlAccountConfig; use super::TomlAccountConfig;
@ -35,6 +36,14 @@ pub(crate) async fn configure() -> Result<Option<(String, TomlAccountConfig)>> {
.interact()?, .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? { match backend::wizard::configure(&account_name, &config.email).await? {
Some(BackendConfig::Maildir(mdir_config)) => { Some(BackendConfig::Maildir(mdir_config)) => {
config.maildir = Some(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))) Ok(Some((account_name, config)))
} }

View file

@ -1,7 +1,7 @@
use anyhow::Result; use anyhow::Result;
use dialoguer::{theme::ColorfulTheme, Confirm, Input, Password, Select}; use dialoguer::{theme::ColorfulTheme, Confirm, Input, Password, Select};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use shellexpand_utils::shellexpand_path; use shellexpand_utils::expand;
use std::{fs, io, path::PathBuf, process}; use std::{fs, io, path::PathBuf, process};
use toml_edit::{Document, Item}; 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()) .default(path.to_string_lossy().to_string())
.interact()?; .interact()?;
let path = shellexpand_path(&path); let path = expand::path(&path);
println!("Writing the configuration to {path:?}"); println!("Writing the configuration to {path:?}");

View file

@ -1,7 +1,7 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use clap::Parser; use clap::Parser;
use log::info; use log::info;
use std::fs; use std::{fs, path::PathBuf};
use uuid::Uuid; use uuid::Uuid;
use crate::{ use crate::{
@ -67,6 +67,8 @@ impl AttachmentDownloadCommand {
for attachment in attachments { for attachment in attachments {
let filename = attachment let filename = attachment
.filename .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()); .unwrap_or_else(|| Uuid::new_v4().to_string());
let filepath = account_config.download_fpath(&filename)?; let filepath = account_config.download_fpath(&filename)?;
printer.print_log(format!("Downloading {:?}", filepath))?; printer.print_log(format!("Downloading {:?}", filepath))?;

View file

@ -1,8 +1,7 @@
use anyhow::Result; use anyhow::Result;
use atty::Stream;
use clap::Parser; use clap::Parser;
use log::info; use log::info;
use std::io::{self, BufRead}; use std::io::{self, BufRead, IsTerminal};
use crate::{ use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag, account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag,
@ -40,7 +39,7 @@ impl MessageSaveCommand {
config.clone().into_account_configs(account, cache)?; config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), true).await?; 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 is_json = printer.is_json();
let msg = if is_tty || is_json { let msg = if is_tty || is_json {
self.message.raw() self.message.raw()

View file

@ -1,9 +1,8 @@
use anyhow::Result; use anyhow::Result;
use atty::Stream;
use clap::Parser; use clap::Parser;
use email::flag::Flag; use email::flag::Flag;
use log::info; use log::info;
use std::io::{self, BufRead}; use std::io::{self, BufRead, IsTerminal};
use crate::{ use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag, 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 backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let folder = account_config.sent_folder_alias()?; 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 is_json = printer.is_json();
let msg = if is_tty || is_json { let msg = if is_tty || is_json {
self.message.raw() self.message.raw()

View file

@ -1,9 +1,8 @@
use anyhow::Result; use anyhow::Result;
use atty::Stream;
use clap::Parser; use clap::Parser;
use log::info; use log::info;
use mml::MmlCompilerBuilder; use mml::MmlCompilerBuilder;
use std::io::{self, BufRead}; use std::io::{self, BufRead, IsTerminal};
use crate::{ use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag, account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag,
@ -44,7 +43,7 @@ impl TemplateSaveCommand {
config.clone().into_account_configs(account, cache)?; config.clone().into_account_configs(account, cache)?;
let backend = Backend::new(toml_account_config, account_config.clone(), false).await?; 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 is_json = printer.is_json();
let tpl = if is_tty || is_json { let tpl = if is_tty || is_json {
self.template.raw() self.template.raw()

View file

@ -1,10 +1,9 @@
use anyhow::Result; use anyhow::Result;
use atty::Stream;
use clap::Parser; use clap::Parser;
use email::flag::Flag; use email::flag::Flag;
use log::info; use log::info;
use mml::MmlCompilerBuilder; use mml::MmlCompilerBuilder;
use std::io::{self, BufRead}; use std::io::{self, BufRead, IsTerminal};
use crate::{ use crate::{
account::arg::name::AccountNameFlag, backend::Backend, cache::arg::disable::CacheDisableFlag, 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 backend = Backend::new(toml_account_config, account_config.clone(), true).await?;
let folder = account_config.sent_folder_alias()?; 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 is_json = printer.is_json();
let tpl = if is_tty || is_json { let tpl = if is_tty || is_json {
self.template.raw() self.template.raw()

View file

@ -1,8 +1,11 @@
use anyhow::{anyhow, Error, Result}; use anyhow::{anyhow, Error, Result};
use atty::Stream;
use clap::ValueEnum; use clap::ValueEnum;
use serde::Serialize; use serde::Serialize;
use std::{fmt, str::FromStr}; use std::{
fmt,
io::{self, IsTerminal},
str::FromStr,
};
use termcolor::ColorChoice; use termcolor::ColorChoice;
/// Represents the available output formats. /// Represents the available output formats.
@ -78,7 +81,7 @@ impl From<ColorFmt> for ColorChoice {
ColorFmt::Always => Self::Always, ColorFmt::Always => Self::Always,
ColorFmt::Ansi => Self::AlwaysAnsi, ColorFmt::Ansi => Self::AlwaysAnsi,
ColorFmt::Auto => { ColorFmt::Auto => {
if atty::is(Stream::Stdout) { if io::stdout().is_terminal() {
// Otherwise let's `termcolor` decide by // Otherwise let's `termcolor` decide by
// inspecting the environment. From the [doc]: // inspecting the environment. From the [doc]:
// //