diff --git a/src/domain/mbox/arg.rs b/src/domain/mbox/arg.rs index bfa4e0db..5d58f0f4 100644 --- a/src/domain/mbox/arg.rs +++ b/src/domain/mbox/arg.rs @@ -44,4 +44,5 @@ pub fn target_arg<'a>() -> Arg<'a, 'a> { Arg::with_name("target") .help("Specifies the targetted mailbox") .value_name("TARGET") + .required(true) } diff --git a/src/domain/mbox/entity.rs b/src/domain/mbox/entity.rs index 1541a164..0b9550f1 100644 --- a/src/domain/mbox/entity.rs +++ b/src/domain/mbox/entity.rs @@ -152,7 +152,9 @@ impl TryFrom> for Mbox { fn try_from(mbox: Option<&str>) -> Result { debug!("init mailbox from `{:?}`", mbox); Ok(Self { - name: mbox.ok_or(anyhow!("cannot parse mailbox"))?.to_string(), + name: mbox + .ok_or(anyhow!("the target mailbox cannot be empty"))? + .to_string(), ..Self::default() }) } diff --git a/src/domain/msg/arg.rs b/src/domain/msg/arg.rs index 40da564c..6412e289 100644 --- a/src/domain/msg/arg.rs +++ b/src/domain/msg/arg.rs @@ -288,7 +288,7 @@ pub fn subcmds<'a>() -> Vec> { .arg(uid_arg()) .arg(msg::attachment::arg::path_arg()), SubCommand::with_name("copy") - .aliases(&["cp"]) + .aliases(&["cp", "c"]) .about("Copies a message to the targetted mailbox") .arg(uid_arg()) .arg(mbox::arg::target_arg()), diff --git a/src/domain/msg/handler.rs b/src/domain/msg/handler.rs index d74404ad..61d6c4c9 100644 --- a/src/domain/msg/handler.rs +++ b/src/domain/msg/handler.rs @@ -149,7 +149,8 @@ pub fn attachments( +/// Copy the given message UID to the targetted mailbox. +pub fn copy( uid: &str, mbox: Option<&str>, output: &OutputService, @@ -157,12 +158,10 @@ pub fn copy( ) -> Result<()> { let target = Mbox::try_from(mbox)?; let mut msg = imap.get_msg(&uid)?; - // the message, which will be in the new mailbox doesn't need to be seen msg.flags.insert(Flag::Seen); imap.append_msg(&target, &mut msg)?; - debug!("message {} successfully copied to folder `{}`", uid, target); output.print(format!( - "Message {} successfully copied to folder `{}`", + r#"Message {} successfully copied to folder "{}""#, uid, target ))?; imap.logout()?;