mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 21:37:55 +08:00
+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