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
+8 -7
View File
@@ -5,9 +5,10 @@ use pimalaya_toolbox::terminal::printer::Printer;
use crate::jmap::{
account::JmapAccount,
email::{
copy::JmapEmailCopyCommand, delete::JmapEmailDestroyCommand, export::ExportEmailCommand,
get::JmapEmailGetCommand, import::ImportEmailCommand, parse::ParseEmailCommand,
query::JmapEmailQueryCommand, read::ReadEmailCommand, update::JmapEmailUpdateCommand,
copy::JmapEmailCopyCommand, delete::JmapEmailDestroyCommand,
export::JmapEmailExportCommand, get::JmapEmailGetCommand, import::JmapEmailImportCommand,
parse::JmapEmailParseCommand, query::JmapEmailQueryCommand, read::JmapEmailReadCommand,
update::JmapEmailUpdateCommand,
},
};
@@ -17,15 +18,15 @@ use crate::jmap::{
pub enum JmapEmailCommand {
Get(JmapEmailGetCommand),
Query(JmapEmailQueryCommand),
Read(ReadEmailCommand),
Read(JmapEmailReadCommand),
#[command(alias = "edit")]
Update(JmapEmailUpdateCommand),
#[command(aliases = ["remove", "rm"])]
Delete(JmapEmailDestroyCommand),
Copy(JmapEmailCopyCommand),
Export(ExportEmailCommand),
Import(ImportEmailCommand),
Parse(ParseEmailCommand),
Export(JmapEmailExportCommand),
Import(JmapEmailImportCommand),
Parse(JmapEmailParseCommand),
}
impl JmapEmailCommand {
+1 -1
View File
@@ -6,7 +6,7 @@ use io_jmap::{
rfc8621::coroutines::email_copy::{JmapEmailCopy, JmapEmailCopyResult},
rfc8621::types::email::EmailCopy,
};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
use crate::jmap::account::JmapAccount;
+1 -1
View File
@@ -1,7 +1,7 @@
use anyhow::{bail, Result};
use clap::Parser;
use io_jmap::rfc8621::coroutines::email_set::{JmapEmailSet, JmapEmailSetArgs, JmapEmailSetResult};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
use crate::jmap::account::JmapAccount;
+3 -3
View File
@@ -7,7 +7,7 @@ use io_jmap::{
},
rfc8621::coroutines::email_get::{JmapEmailGet, JmapEmailGetResult},
};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
use url::Url;
@@ -17,13 +17,13 @@ use crate::jmap::account::JmapAccount;
///
/// Fetches the blobId via Email/get then downloads the raw message blob.
#[derive(Debug, Parser)]
pub struct ExportEmailCommand {
pub struct JmapEmailExportCommand {
/// The email ID to export.
#[arg(value_name = "ID")]
pub id: String,
}
impl ExportEmailCommand {
impl JmapEmailExportCommand {
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
let tls = account.backend.tls.clone().try_into()?;
let mut jmap = account.new_jmap_session()?;
+1 -1
View File
@@ -1,7 +1,7 @@
use anyhow::{bail, Result};
use clap::Parser;
use io_jmap::rfc8621::coroutines::email_get::{JmapEmailGet, JmapEmailGetResult};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use log::warn;
use pimalaya_toolbox::terminal::printer::Printer;
+3 -3
View File
@@ -15,7 +15,7 @@ use io_jmap::{
types::email::EmailImport,
},
};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
use url::Url;
@@ -26,7 +26,7 @@ use crate::jmap::account::JmapAccount;
/// Reads the raw message from stdin or as trailing arguments. Use
/// `--upload-only` to stop after the upload and print the blobId.
#[derive(Debug, Parser)]
pub struct ImportEmailCommand {
pub struct JmapEmailImportCommand {
/// Mailbox ID(s) to place the imported email in.
#[arg(long, value_name = "MAILBOX-ID")]
pub mailbox_id: Vec<String>,
@@ -49,7 +49,7 @@ pub struct ImportEmailCommand {
pub message: Vec<String>,
}
impl ImportEmailCommand {
impl JmapEmailImportCommand {
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
let tls = account.backend.tls.clone().try_into()?;
let mut jmap = account.new_jmap_session()?;
+3 -3
View File
@@ -1,7 +1,7 @@
use anyhow::{bail, Result};
use clap::Parser;
use io_jmap::rfc8621::coroutines::email_parse::{JmapEmailParse, JmapEmailParseResult};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use log::warn;
use pimalaya_toolbox::terminal::printer::Printer;
use serde::Serialize;
@@ -13,13 +13,13 @@ use crate::jmap::account::JmapAccount;
/// Useful for reading attached .eml files or message blobs that are
/// not yet stored as Email objects.
#[derive(Debug, Parser)]
pub struct ParseEmailCommand {
pub struct JmapEmailParseCommand {
/// Blob ID(s) to parse as RFC 5322 messages.
#[arg(value_name = "ID", required = true)]
pub blob_ids: Vec<String>,
}
impl ParseEmailCommand {
impl JmapEmailParseCommand {
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
let mut jmap = account.new_jmap_session()?;
+1 -1
View File
@@ -7,7 +7,7 @@ use io_jmap::{
rfc8621::coroutines::email_query::{JmapEmailQuery, JmapEmailQueryResult},
rfc8621::types::email::{Email, EmailAddress, EmailComparator, EmailFilter, EmailSortProperty},
};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use pimalaya_toolbox::terminal::printer::Printer;
use serde::Serialize;
+3 -3
View File
@@ -4,7 +4,7 @@ use io_jmap::{
rfc8621::coroutines::email_get::{JmapEmailGet, JmapEmailGetResult},
rfc8621::types::email::EmailAddress,
};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use log::warn;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
@@ -14,7 +14,7 @@ use crate::jmap::account::JmapAccount;
///
/// Shows headers and plain text body by default.
#[derive(Debug, Parser)]
pub struct ReadEmailCommand {
pub struct JmapEmailReadCommand {
/// The email ID(s) to read.
#[arg(value_name = "ID", required = true)]
pub ids: Vec<String>,
@@ -24,7 +24,7 @@ pub struct ReadEmailCommand {
pub html: bool,
}
impl ReadEmailCommand {
impl JmapEmailReadCommand {
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
let mut jmap = account.new_jmap_session()?;
+1 -1
View File
@@ -3,7 +3,7 @@ use std::collections::HashMap;
use anyhow::{bail, Result};
use clap::Parser;
use io_jmap::rfc8621::coroutines::email_set::{JmapEmailSet, JmapEmailSetArgs, JmapEmailSetResult};
use io_stream::runtimes::std::handle;
use io_socket::runtimes::std_stream::handle;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
use crate::jmap::account::JmapAccount;