mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-15 11:27:53 +08:00
Generated
+13
-1
@@ -1061,7 +1061,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "io-email"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/pimalaya/io-email#15aeedd215b5edf463e8b3cae8bbd4ae223e5cff"
|
||||
source = "git+https://github.com/pimalaya/io-email#046c1c051f497fc84d72763a22abc55d4335ea8a"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"chumsky",
|
||||
@@ -1077,6 +1077,7 @@ dependencies = [
|
||||
"serde",
|
||||
"thiserror",
|
||||
"url",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2453,6 +2454,17 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76"
|
||||
dependencies = [
|
||||
"getrandom 0.4.2",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[features]
|
||||
default = ["imap", "smtp", "jmap", "maildir", "rustls-ring"]
|
||||
default = ["imap", "smtp", "rustls-ring"]
|
||||
imap = ["dep:io-imap", "dep:mail-parser", "dep:rfc2047-decoder", "io-email/imap", "io-imap/client"]
|
||||
jmap = ["dep:base64", "dep:io-jmap", "dep:mail-parser", "dep:serde_json", "io-email/jmap", "io-jmap/client"]
|
||||
smtp = ["dep:io-smtp", "dep:mail-parser", "io-email/smtp"]
|
||||
|
||||
+10
-2
@@ -35,8 +35,12 @@ use serde::{Deserialize, Serialize};
|
||||
/// Global configuration.
|
||||
///
|
||||
/// Represents the whole TOML user's configuration file.
|
||||
/// `deny_unknown_fields` is intentionally omitted so the same TOML
|
||||
/// file can be shared with `himalaya-tui`: top-level TUI-only fields
|
||||
/// (`display-name`, `signature`, `signature-delim`) are silently
|
||||
/// ignored here.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Config {
|
||||
pub downloads_dir: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
@@ -98,8 +102,12 @@ impl Config {
|
||||
}
|
||||
|
||||
/// Account configuration.
|
||||
///
|
||||
/// `deny_unknown_fields` is omitted so per-account TUI-only fields
|
||||
/// (`email`, `display-name`, `signature`, `signature-delim`) coexist
|
||||
/// in the same `[accounts.<name>]` block when the file is shared.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct AccountConfig {
|
||||
#[serde(default)]
|
||||
pub default: bool,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{
|
||||
fmt,
|
||||
io::{IsTerminal, Read, stdin},
|
||||
path::PathBuf,
|
||||
};
|
||||
@@ -23,8 +24,8 @@ use std::{
|
||||
use anyhow::{Result, bail};
|
||||
use clap::Parser;
|
||||
use io_email::flag::Flag;
|
||||
use pimalaya_cli::printer::Message;
|
||||
use pimalaya_cli::printer::Printer;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::shared::{client::EmailClient, flags::arg::FlagArg};
|
||||
|
||||
@@ -55,8 +56,19 @@ impl MessageAddCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, mut client: EmailClient) -> Result<()> {
|
||||
let raw = read_raw(&self.file)?;
|
||||
let flags: Vec<Flag> = self.flag.iter().map(Into::into).collect();
|
||||
client.add_message(&self.mailbox, &flags, raw)?;
|
||||
printer.out(Message::new("Message successfully added"))
|
||||
let id = client.add_message(&self.mailbox, &flags, raw)?;
|
||||
printer.out(MessageAddOutput { id })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct MessageAddOutput {
|
||||
id: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for MessageAddOutput {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Message {} successfully added", self.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user