mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-19 23:25:14 +08:00
refactor: unify command names
This commit is contained in:
+9
-9
@@ -3,10 +3,10 @@ use clap::Subcommand;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
|
||||
use crate::jmap::{
|
||||
account::JmapAccount, email::command::JmapEmailCommand, identity::command::IdentityCommand,
|
||||
mailbox::command::JmapMailboxCommand, query::QueryCommand,
|
||||
submission::command::SubmissionCommand, thread::command::ThreadCommand,
|
||||
vacation::command::VacationCommand,
|
||||
account::JmapAccount, email::command::JmapEmailCommand, identity::command::JmapIdentityCommand,
|
||||
mailbox::command::JmapMailboxCommand, query::JmapQueryCommand,
|
||||
submission::command::JmapSubmissionCommand, thread::command::JmapThreadCommand,
|
||||
vacation::command::JmapVacationCommand,
|
||||
};
|
||||
|
||||
/// JMAP CLI (requires the `jmap` cargo feature).
|
||||
@@ -26,17 +26,17 @@ pub enum JmapCommand {
|
||||
Emails(JmapEmailCommand),
|
||||
|
||||
#[command(subcommand)]
|
||||
Threads(ThreadCommand),
|
||||
Threads(JmapThreadCommand),
|
||||
#[command(subcommand)]
|
||||
#[command(aliases = ["identities"])]
|
||||
Identity(IdentityCommand),
|
||||
Identity(JmapIdentityCommand),
|
||||
#[command(subcommand)]
|
||||
#[command(aliases = ["submissions", "submit"])]
|
||||
Submission(SubmissionCommand),
|
||||
Submission(JmapSubmissionCommand),
|
||||
#[command(subcommand)]
|
||||
#[command(alias = "vacation-response")]
|
||||
Vacation(VacationCommand),
|
||||
Query(QueryCommand),
|
||||
Vacation(JmapVacationCommand),
|
||||
Query(JmapQueryCommand),
|
||||
}
|
||||
|
||||
impl JmapCommand {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,29 +5,29 @@ use pimalaya_toolbox::terminal::printer::Printer;
|
||||
use crate::jmap::{
|
||||
account::JmapAccount,
|
||||
identity::{
|
||||
create::JmapIdentityCreateCommand, delete::DeleteIdentityCommand, get::GetIdentityCommand,
|
||||
update::UpdateIdentityCommand,
|
||||
create::JmapIdentityCreateCommand, delete::JmapIdentityDeleteCommand,
|
||||
get::JmapIdentityGetCommand, update::JmapIdentityUpdateCommand,
|
||||
},
|
||||
};
|
||||
|
||||
/// Manage JMAP sender identities.
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum IdentityCommand {
|
||||
pub enum JmapIdentityCommand {
|
||||
/// Fetch identities (Identity/get).
|
||||
#[command(aliases = ["lst", "list"])]
|
||||
Get(GetIdentityCommand),
|
||||
Get(JmapIdentityGetCommand),
|
||||
/// Create a new identity (Identity/set).
|
||||
#[command(aliases = ["add", "new"])]
|
||||
Create(JmapIdentityCreateCommand),
|
||||
/// Update an existing identity (Identity/set).
|
||||
#[command(alias = "edit")]
|
||||
Update(UpdateIdentityCommand),
|
||||
Update(JmapIdentityUpdateCommand),
|
||||
/// Delete an identity (Identity/set).
|
||||
#[command(aliases = ["remove", "rm"])]
|
||||
Delete(DeleteIdentityCommand),
|
||||
Delete(JmapIdentityDeleteCommand),
|
||||
}
|
||||
|
||||
impl IdentityCommand {
|
||||
impl JmapIdentityCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
match self {
|
||||
Self::Get(cmd) => cmd.execute(printer, account),
|
||||
|
||||
@@ -6,7 +6,7 @@ use io_jmap::{
|
||||
},
|
||||
rfc8621::types::identity::IdentityCreate,
|
||||
};
|
||||
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,20 +3,20 @@ use clap::Parser;
|
||||
use io_jmap::rfc8621::coroutines::identity_set::{
|
||||
JmapIdentitySet, JmapIdentitySetArgs, JmapIdentitySetResult,
|
||||
};
|
||||
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;
|
||||
|
||||
/// Delete a JMAP sender identity (Identity/set).
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct DeleteIdentityCommand {
|
||||
pub struct JmapIdentityDeleteCommand {
|
||||
/// Identity ID(s) to delete.
|
||||
#[arg(value_name = "ID", required = true)]
|
||||
pub ids: Vec<String>,
|
||||
}
|
||||
|
||||
impl DeleteIdentityCommand {
|
||||
impl JmapIdentityDeleteCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use io_jmap::{
|
||||
rfc8621::coroutines::identity_get::{JmapIdentityGet, JmapIdentityGetResult},
|
||||
rfc8621::types::identity::Identity,
|
||||
};
|
||||
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;
|
||||
@@ -19,13 +19,13 @@ use crate::jmap::account::JmapAccount;
|
||||
/// Lists sender identities available for sending email. Pass no IDs to
|
||||
/// list all identities.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct GetIdentityCommand {
|
||||
pub struct JmapIdentityGetCommand {
|
||||
/// Identity ID(s) to retrieve (omit to get all).
|
||||
#[arg(value_name = "ID")]
|
||||
pub ids: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl GetIdentityCommand {
|
||||
impl JmapIdentityGetCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ use io_jmap::{
|
||||
},
|
||||
rfc8621::types::identity::IdentityUpdate,
|
||||
};
|
||||
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;
|
||||
|
||||
/// Update a JMAP sender identity (Identity/set).
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct UpdateIdentityCommand {
|
||||
pub struct JmapIdentityUpdateCommand {
|
||||
/// Identity ID to update.
|
||||
pub id: String,
|
||||
|
||||
@@ -30,7 +30,7 @@ pub struct UpdateIdentityCommand {
|
||||
pub html_signature: Option<String>,
|
||||
}
|
||||
|
||||
impl UpdateIdentityCommand {
|
||||
impl JmapIdentityUpdateCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use io_jmap::{
|
||||
rfc8621::coroutines::mailbox_set::{JmapMailboxSet, JmapMailboxSetArgs, JmapMailboxSetResult},
|
||||
rfc8621::types::mailbox::MailboxCreate,
|
||||
};
|
||||
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,7 +3,7 @@ use clap::Parser;
|
||||
use io_jmap::rfc8621::coroutines::mailbox_set::{
|
||||
JmapMailboxSet, JmapMailboxSetArgs, JmapMailboxSetResult,
|
||||
};
|
||||
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,7 +1,7 @@
|
||||
use anyhow::{bail, Result};
|
||||
use clap::Parser;
|
||||
use io_jmap::rfc8621::coroutines::mailbox_get::{JmapMailboxGet, JmapMailboxGetResult};
|
||||
use io_stream::runtimes::std::handle;
|
||||
use io_socket::runtimes::std_stream::handle;
|
||||
use log::warn;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use io_jmap::{
|
||||
Mailbox, MailboxFilter, MailboxRole, MailboxSortComparator, MailboxSortProperty,
|
||||
},
|
||||
};
|
||||
use io_stream::runtimes::std::handle;
|
||||
use io_socket::runtimes::std_stream::handle;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
use serde::Serialize;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use io_jmap::{
|
||||
rfc8621::coroutines::mailbox_set::{JmapMailboxSet, JmapMailboxSetArgs, JmapMailboxSetResult},
|
||||
rfc8621::types::mailbox::MailboxUpdate,
|
||||
};
|
||||
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, mailbox::query::RoleArg};
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ use io_jmap::rfc8620::{
|
||||
coroutines::send::{JmapRequest, JmapSend, JmapSendResult},
|
||||
types::session::capabilities::{CORE, MAIL},
|
||||
};
|
||||
use io_stream::runtimes::std::handle;
|
||||
use io_socket::runtimes::std_stream::handle;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
@@ -26,7 +26,7 @@ use crate::jmap::account::JmapAccount;
|
||||
/// automatically if not already present. Pass `-` or omit to read
|
||||
/// from stdin.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct QueryCommand {
|
||||
pub struct JmapQueryCommand {
|
||||
/// Extra capability URNs to declare (core and mail are always included).
|
||||
#[arg(long = "using", value_name = "URN")]
|
||||
pub using: Vec<String>,
|
||||
@@ -37,7 +37,7 @@ pub struct QueryCommand {
|
||||
pub method_calls: Vec<String>,
|
||||
}
|
||||
|
||||
impl QueryCommand {
|
||||
impl JmapQueryCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use clap::Parser;
|
||||
use io_jmap::rfc8621::coroutines::email_submission_cancel::{
|
||||
JmapEmailSubmissionCancel, JmapEmailSubmissionCancelResult,
|
||||
};
|
||||
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;
|
||||
@@ -13,13 +13,13 @@ use crate::jmap::account::JmapAccount;
|
||||
/// Only submissions with `undoStatus: "pending"` can be canceled.
|
||||
/// The server may reject this if the message has already been sent.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct CancelSubmissionCommand {
|
||||
pub struct JmapSubmissionCancelCommand {
|
||||
/// Submission ID(s) to cancel.
|
||||
#[arg(value_name = "ID", required = true)]
|
||||
pub ids: Vec<String>,
|
||||
}
|
||||
|
||||
impl CancelSubmissionCommand {
|
||||
impl JmapSubmissionCancelCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -5,27 +5,27 @@ use pimalaya_toolbox::terminal::printer::Printer;
|
||||
use crate::jmap::{
|
||||
account::JmapAccount,
|
||||
submission::{
|
||||
cancel::CancelSubmissionCommand, create::CreateSubmissionCommand,
|
||||
get::GetSubmissionCommand, query::QuerySubmissionCommand,
|
||||
cancel::JmapSubmissionCancelCommand, create::JmapSubmissionCreateCommand,
|
||||
get::JmapSubmissionGetCommand, query::JmapSubmissionQueryCommand,
|
||||
},
|
||||
};
|
||||
|
||||
/// Manage JMAP email submissions.
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum SubmissionCommand {
|
||||
pub enum JmapSubmissionCommand {
|
||||
/// Fetch submissions by ID (EmailSubmission/get).
|
||||
Get(GetSubmissionCommand),
|
||||
Get(JmapSubmissionGetCommand),
|
||||
/// Query and list submissions (EmailSubmission/query + EmailSubmission/get).
|
||||
#[command(aliases = ["lst", "list"])]
|
||||
Query(QuerySubmissionCommand),
|
||||
Query(JmapSubmissionQueryCommand),
|
||||
/// Submit a draft email for sending (EmailSubmission/set).
|
||||
#[command(aliases = ["send", "submit"])]
|
||||
Create(CreateSubmissionCommand),
|
||||
Create(JmapSubmissionCreateCommand),
|
||||
/// Cancel a pending submission (EmailSubmission/set).
|
||||
Cancel(CancelSubmissionCommand),
|
||||
Cancel(JmapSubmissionCancelCommand),
|
||||
}
|
||||
|
||||
impl SubmissionCommand {
|
||||
impl JmapSubmissionCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
match self {
|
||||
Self::Get(cmd) => cmd.execute(printer, account),
|
||||
|
||||
@@ -10,7 +10,7 @@ use io_jmap::{
|
||||
EmailAddressWithParameters, EmailSubmissionCreate, Envelope,
|
||||
},
|
||||
};
|
||||
use io_stream::runtimes::std::handle;
|
||||
use io_socket::runtimes::std_stream::handle;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
|
||||
use crate::jmap::{account::JmapAccount, submission::query::SubmissionsTable};
|
||||
@@ -20,7 +20,7 @@ use crate::jmap::{account::JmapAccount, submission::query::SubmissionsTable};
|
||||
/// The email must already exist as a draft in the JMAP account.
|
||||
/// This is the JMAP equivalent of SMTP message submission.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct CreateSubmissionCommand {
|
||||
pub struct JmapSubmissionCreateCommand {
|
||||
/// The ID of the draft email to send.
|
||||
#[arg(value_name = "EMAIL_ID")]
|
||||
pub email_id: String,
|
||||
@@ -38,7 +38,7 @@ pub struct CreateSubmissionCommand {
|
||||
pub rcpt_to: Vec<String>,
|
||||
}
|
||||
|
||||
impl CreateSubmissionCommand {
|
||||
impl JmapSubmissionCreateCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use clap::Parser;
|
||||
use io_jmap::rfc8621::coroutines::email_submission_get::{
|
||||
JmapEmailSubmissionGet, JmapEmailSubmissionGetResult,
|
||||
};
|
||||
use io_stream::runtimes::std::handle;
|
||||
use io_socket::runtimes::std_stream::handle;
|
||||
use log::warn;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
|
||||
@@ -11,13 +11,13 @@ use crate::jmap::{account::JmapAccount, submission::query::SubmissionsTable};
|
||||
|
||||
/// Get JMAP email submissions by ID (EmailSubmission/get).
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct GetSubmissionCommand {
|
||||
pub struct JmapSubmissionGetCommand {
|
||||
/// Submission ID(s) to retrieve.
|
||||
#[arg(value_name = "ID", required = true)]
|
||||
pub ids: Vec<String>,
|
||||
}
|
||||
|
||||
impl GetSubmissionCommand {
|
||||
impl JmapSubmissionGetCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use io_jmap::{
|
||||
},
|
||||
rfc8621::types::email_submission::{EmailSubmission, EmailSubmissionFilter, UndoStatus},
|
||||
};
|
||||
use io_stream::runtimes::std::handle;
|
||||
use io_socket::runtimes::std_stream::handle;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -35,7 +35,7 @@ impl From<UndoStatusArg> for UndoStatus {
|
||||
|
||||
/// Query JMAP email submissions (EmailSubmission/query + EmailSubmission/get).
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct QuerySubmissionCommand {
|
||||
pub struct JmapSubmissionQueryCommand {
|
||||
/// Filter by undo status (`pending`, `final`, `canceled`).
|
||||
#[arg(long, value_name = "STATUS")]
|
||||
pub undo_status: Option<UndoStatusArg>,
|
||||
@@ -57,7 +57,7 @@ pub struct QuerySubmissionCommand {
|
||||
pub page: u64,
|
||||
}
|
||||
|
||||
impl QuerySubmissionCommand {
|
||||
impl JmapSubmissionQueryCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@ use anyhow::Result;
|
||||
use clap::Subcommand;
|
||||
use pimalaya_toolbox::terminal::printer::Printer;
|
||||
|
||||
use crate::jmap::{account::JmapAccount, thread::get::GetThreadCommand};
|
||||
use crate::jmap::{account::JmapAccount, thread::get::JmapThreadGetCommand};
|
||||
|
||||
/// Manage JMAP threads.
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum ThreadCommand {
|
||||
pub enum JmapThreadCommand {
|
||||
/// Fetch threads by ID (Thread/get).
|
||||
Get(GetThreadCommand),
|
||||
Get(JmapThreadGetCommand),
|
||||
}
|
||||
|
||||
impl ThreadCommand {
|
||||
impl JmapThreadCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
match self {
|
||||
Self::Get(cmd) => cmd.execute(printer, account),
|
||||
|
||||
@@ -7,7 +7,7 @@ use io_jmap::{
|
||||
rfc8621::coroutines::thread_get::{JmapThreadGet, JmapThreadGetResult},
|
||||
rfc8621::types::thread::Thread,
|
||||
};
|
||||
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;
|
||||
@@ -18,13 +18,13 @@ use crate::jmap::account::JmapAccount;
|
||||
///
|
||||
/// Each thread contains an ordered list of email IDs in the thread.
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct GetThreadCommand {
|
||||
pub struct JmapThreadGetCommand {
|
||||
/// Thread ID(s) to retrieve.
|
||||
#[arg(value_name = "ID", required = true)]
|
||||
pub ids: Vec<String>,
|
||||
}
|
||||
|
||||
impl GetThreadCommand {
|
||||
impl JmapThreadGetCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -4,19 +4,19 @@ use pimalaya_toolbox::terminal::printer::Printer;
|
||||
|
||||
use crate::jmap::{
|
||||
account::JmapAccount,
|
||||
vacation::{get::GetVacationCommand, set::SetVacationCommand},
|
||||
vacation::{get::JmapVacationGetCommand, set::JmapVacationSetCommand},
|
||||
};
|
||||
|
||||
/// Manage JMAP vacation response.
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum VacationCommand {
|
||||
pub enum JmapVacationCommand {
|
||||
/// Get the vacation response (VacationResponse/get).
|
||||
Get(GetVacationCommand),
|
||||
Get(JmapVacationGetCommand),
|
||||
/// Update the vacation response (VacationResponse/set).
|
||||
Set(SetVacationCommand),
|
||||
Set(JmapVacationSetCommand),
|
||||
}
|
||||
|
||||
impl VacationCommand {
|
||||
impl JmapVacationCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
match self {
|
||||
Self::Get(cmd) => cmd.execute(printer, account),
|
||||
|
||||
@@ -10,7 +10,7 @@ use io_jmap::{
|
||||
},
|
||||
rfc8621::types::vacation_response::VacationResponse,
|
||||
};
|
||||
use io_stream::runtimes::std::handle;
|
||||
use io_socket::runtimes::std_stream::handle;
|
||||
use pimalaya_toolbox::terminal::printer::{Message, Printer};
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -18,9 +18,9 @@ use crate::jmap::account::JmapAccount;
|
||||
|
||||
/// Get the JMAP vacation response (VacationResponse/get).
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct GetVacationCommand;
|
||||
pub struct JmapVacationGetCommand;
|
||||
|
||||
impl GetVacationCommand {
|
||||
impl JmapVacationGetCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ use io_jmap::{
|
||||
},
|
||||
rfc8621::types::vacation_response::VacationResponseUpdate,
|
||||
};
|
||||
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;
|
||||
|
||||
/// Update the JMAP vacation response (VacationResponse/set).
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct SetVacationCommand {
|
||||
pub struct JmapVacationSetCommand {
|
||||
/// Enable the vacation response.
|
||||
#[arg(long, conflicts_with = "disable")]
|
||||
pub enable: bool,
|
||||
@@ -44,7 +44,7 @@ pub struct SetVacationCommand {
|
||||
pub html_body: Option<String>,
|
||||
}
|
||||
|
||||
impl SetVacationCommand {
|
||||
impl JmapVacationSetCommand {
|
||||
pub fn execute(self, printer: &mut impl Printer, account: JmapAccount) -> Result<()> {
|
||||
let mut jmap = account.new_jmap_session()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user