refactor: unify command names

This commit is contained in:
Clément DOUIN
2026-04-02 21:24:14 +02:00
parent 9ffcfcb1ba
commit b295f159de
91 changed files with 763 additions and 825 deletions
+10 -8
View File
@@ -3,13 +3,13 @@ use std::io::{stdin, BufRead, IsTerminal};
use anyhow::{bail, Result};
use clap::Parser;
use io_imap::{
coroutines::append::*,
rfc3501::append::*,
types::{
core::Literal, extensions::binary::LiteralOrLiteral8, flag::Flag, mailbox::Mailbox,
IntoStatic,
},
};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
use crate::imap::{account::ImapAccount, mailbox::arg::MailboxNameArg};
@@ -19,7 +19,7 @@ use crate::imap::{account::ImapAccount, mailbox::arg::MailboxNameArg};
/// This command appends a message to the specified mailbox. The
/// message is read from stdin in RFC 5322 format (raw email).
#[derive(Debug, Parser)]
pub struct SaveMessageCommand {
pub struct ImapMessageSaveCommand {
#[command(flatten)]
pub mailbox: MailboxNameArg,
@@ -33,7 +33,7 @@ pub struct SaveMessageCommand {
pub message: Vec<String>,
}
impl SaveMessageCommand {
impl ImapMessageSaveCommand {
pub fn execute(self, printer: &mut impl Printer, account: ImapAccount) -> Result<()> {
let mut imap = account.new_imap_session()?;
let mailbox: Mailbox<'static> = self.mailbox.inner.try_into()?;
@@ -61,13 +61,15 @@ impl SaveMessageCommand {
.collect::<Result<_, _>>()?;
let mut arg = None;
let mut coroutine = ImapAppend::new(imap.context, mailbox, flags, None, message);
let mut coroutine = ImapMessageAppend::new(imap.context, mailbox, flags, None, message);
loop {
match coroutine.resume(arg.take()) {
ImapAppendResult::Io { io } => arg = Some(handle(&mut imap.stream, io)?),
ImapAppendResult::Ok { .. } => break,
ImapAppendResult::Err { err, .. } => bail!(err),
ImapMessageAppendResult::Io { input } => {
arg = Some(handle(&mut imap.stream, input)?)
}
ImapMessageAppendResult::Ok { .. } => break,
ImapMessageAppendResult::Err { err, .. } => bail!(err),
}
}