diff --git a/src/imap/cli.rs b/src/imap/cli.rs index 14d2a6f2..4e5fa170 100644 --- a/src/imap/cli.rs +++ b/src/imap/cli.rs @@ -35,15 +35,15 @@ pub enum ImapCommand { Id(ImapIdCommand), #[command(subcommand)] - #[command(aliases = ["mboxes", "mbox"])] - Mailboxes(ImapMailboxCommand), + #[command(aliases = ["mbox"])] + Mailbox(ImapMailboxCommand), #[command(subcommand)] - Envelopes(ImapEnvelopeCommand), + Envelope(ImapEnvelopeCommand), #[command(subcommand)] - Flags(ImapFlagCommand), + Flag(ImapFlagCommand), #[command(subcommand)] - #[command(aliases = ["msgs", "msg"])] - Messages(ImapMessageCommand), + #[command(aliases = ["msg"])] + Message(ImapMessageCommand), } impl ImapCommand { @@ -56,10 +56,10 @@ impl ImapCommand { match self { Self::Id(cmd) => cmd.execute(printer, account, client), - Self::Envelopes(cmd) => cmd.execute(printer, account, client), - Self::Flags(cmd) => cmd.execute(printer, account, client), - Self::Mailboxes(cmd) => cmd.execute(printer, account, client), - Self::Messages(cmd) => cmd.execute(printer, account, client), + Self::Envelope(cmd) => cmd.execute(printer, account, client), + Self::Flag(cmd) => cmd.execute(printer, account, client), + Self::Mailbox(cmd) => cmd.execute(printer, account, client), + Self::Message(cmd) => cmd.execute(printer, account, client), } } } diff --git a/src/imap/envelope/get.rs b/src/imap/envelope/get.rs index a39a14d2..e6167129 100644 --- a/src/imap/envelope/get.rs +++ b/src/imap/envelope/get.rs @@ -48,7 +48,7 @@ pub struct ImapEnvelopeGetCommand { /// The message UID (or sequence number with --seq). #[arg(name = "id", value_name = "ID")] - pub id: u32, + pub id: String, /// Use sequence numbers instead of UIDs. #[arg(long)] pub seq: bool, @@ -67,14 +67,10 @@ impl ImapEnvelopeGetCommand { client.select(mailbox)?; } - if self.id == 0 { - bail!("ID must be non-zero"); - } - let item_names = MacroOrMessageDataItemNames::MessageDataItemNames(vec![MessageDataItemName::Envelope]); - let sequence_set = self.id.to_string().parse()?; + let sequence_set = self.id.parse()?; let mut data = client.fetch(sequence_set, item_names, !self.seq)?; let Some((_, items)) = data.pop_first() else { diff --git a/src/imap/message/get.rs b/src/imap/message/get.rs index 952c31d2..f3c40798 100644 --- a/src/imap/message/get.rs +++ b/src/imap/message/get.rs @@ -42,7 +42,7 @@ pub struct ImapMessageGetCommand { pub mailbox_no_select: MailboxNoSelectFlag, /// The message UID (or sequence number with --seq). - pub id: u32, + pub id: String, /// Use sequence numbers instead of UIDs. #[arg(long)] pub seq: bool, @@ -51,9 +51,6 @@ pub struct ImapMessageGetCommand { impl ImapMessageGetCommand { pub fn execute(self, printer: &mut impl Printer, client: &mut ImapClient) -> Result<()> { let mailbox = self.mailbox_name.inner.try_into()?; - if self.id == 0 { - bail!("ID must be non-zero"); - } if !self.mailbox_no_select.inner { client.select(mailbox)?; @@ -66,7 +63,7 @@ impl ImapMessageGetCommand { peek: true, }]); - let sequence_set = self.id.to_string().parse()?; + let sequence_set = self.id.parse()?; let mut data = client.fetch(sequence_set, item_names, !self.seq)?; let Some((_, items)) = data.pop_first() else { diff --git a/src/imap/message/read.rs b/src/imap/message/read.rs index a37b1b96..4f0cb21b 100644 --- a/src/imap/message/read.rs +++ b/src/imap/message/read.rs @@ -42,7 +42,7 @@ pub struct ImapMessageReadCommand { /// The message UID (or sequence number with --seq). #[arg(name = "id", value_name = "ID")] - pub id: u32, + pub id: String, /// Use sequence numbers instead of UIDs. #[arg(long)] @@ -61,10 +61,6 @@ impl ImapMessageReadCommand { client.select(mailbox)?; } - if self.id == 0 { - bail!("ID must be non-zero"); - } - let item_names = MacroOrMessageDataItemNames::MessageDataItemNames(vec![MessageDataItemName::BodyExt { section: None, @@ -72,7 +68,7 @@ impl ImapMessageReadCommand { peek: true, }]); - let sequence_set = self.id.to_string().parse()?; + let sequence_set = self.id.parse()?; let mut data = client.fetch(sequence_set, item_names, !self.seq)?; let Some((_, items)) = data.pop_first() else {