diff --git a/src/domain/imap/service.rs b/src/domain/imap/service.rs index 56234a9f..9622ec98 100644 --- a/src/domain/imap/service.rs +++ b/src/domain/imap/service.rs @@ -204,35 +204,22 @@ impl<'a> ImapServiceInterface for ImapService<'a> { Ok(()) } - /// Add the given flags to the given mail. + /// Add flags to the given message UID sequence. /// - /// # Example - /// ```no_run - /// use himalaya::imap::model::ImapConnector; - /// use himalaya::config::model::Account; - /// use himalaya::flag::model::Flags; - /// use imap::types::Flag; + /// ```ignore /// - /// fn main() { - /// let account = Account::default(); - /// let mut imap_conn = ImapConnector::new(&account).unwrap(); - /// let flags = Flags::from(vec![Flag::Seen]); - /// - /// // Mark the message with the UID 42 in the mailbox "rofl" as "Seen" - /// imap_conn.add_flags("rofl", "42", flags).unwrap(); - /// - /// imap_conn.logout(); - /// } + /// let flags = Flags::from(vec![Flag::Seen, Flag::Deleted]); + /// imap.add_flags("5:10", flags) /// ``` fn add_flags(&mut self, uid_seq: &str, flags: Flags) -> Result<()> { let mbox = self.mbox.to_owned(); let flags: String = flags.to_string(); self.sess()? .select(&mbox.name) - .context(format!("cannot select mbox `{}`", self.mbox.name))?; + .context(format!(r#"cannot select mailbox "{}""#, self.mbox.name))?; self.sess()? .uid_store(uid_seq, format!("+FLAGS ({})", flags)) - .context(format!("cannot add flags `{}`", &flags))?; + .context(format!(r#"cannot add flags "{}""#, &flags))?; Ok(()) } diff --git a/src/domain/msg/arg.rs b/src/domain/msg/arg.rs index 6412e289..4a756770 100644 --- a/src/domain/msg/arg.rs +++ b/src/domain/msg/arg.rs @@ -298,7 +298,7 @@ pub fn subcmds<'a>() -> Vec> { .arg(uid_arg()) .arg(mbox::arg::target_arg()), SubCommand::with_name("delete") - .aliases(&["remove", "rm"]) + .aliases(&["del", "d", "remove", "rm"]) .about("Deletes a message") .arg(uid_arg()), ], diff --git a/src/domain/msg/handler.rs b/src/domain/msg/handler.rs index 61d6c4c9..ccacd12f 100644 --- a/src/domain/msg/handler.rs +++ b/src/domain/msg/handler.rs @@ -168,16 +168,16 @@ pub fn copy( +/// Delete the given message UID from the selected mailbox. +pub fn delete( uid: &str, output: &OutputService, imap: &mut ImapService, ) -> Result<()> { - let flags = vec![Flag::Seen, Flag::Deleted]; - imap.add_flags(uid, Flags::from(flags))?; + let flags = Flags::from(vec![Flag::Seen, Flag::Deleted]); + imap.add_flags(uid, flags)?; imap.expunge()?; - debug!("message {} successfully deleted", uid); - output.print(format!("Message {} successfully deleted", uid))?; + output.print(format!("Message(s) {} successfully deleted", uid))?; imap.logout()?; Ok(()) }