mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 13:17:55 +08:00
add silent flag (#74)
This commit is contained in:
+11
-7
@@ -163,6 +163,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
let config = Config::new_from_file()?;
|
||||
let account = config.find_account_by_name(matches.value_of("account"))?;
|
||||
let output_fmt = matches.value_of("output").unwrap();
|
||||
let silent = matches.is_present("silent");
|
||||
let mbox = matches.value_of("mailbox").unwrap();
|
||||
|
||||
if let Some(matches) = matches.subcommand_matches("list") {
|
||||
@@ -171,7 +172,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
let page: usize = matches.value_of("page").unwrap().parse().unwrap();
|
||||
let msgs = imap_conn.list_msgs(&mbox, &page_size, &page)?;
|
||||
let msgs = Msgs::from(&msgs);
|
||||
print(&output_fmt, msgs)?;
|
||||
print(&output_fmt, &silent, msgs)?;
|
||||
imap_conn.logout();
|
||||
return Ok(());
|
||||
}
|
||||
@@ -206,7 +207,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
.join(" ");
|
||||
let msgs = imap_conn.search_msgs(&mbox, &query, &page_size, &page)?;
|
||||
let msgs = Msgs::from(&msgs);
|
||||
print(&output_fmt, msgs)?;
|
||||
print(&output_fmt, &silent, msgs)?;
|
||||
imap_conn.logout();
|
||||
return Ok(());
|
||||
}
|
||||
@@ -217,7 +218,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
let mime = format!("text/{}", matches.value_of("mime-type").unwrap());
|
||||
let msg = imap_conn.read_msg(&mbox, &uid)?;
|
||||
let msg = ReadableMsg::from_bytes(&mime, &msg)?;
|
||||
print(&output_fmt, msg)?;
|
||||
print(&output_fmt, &silent, msg)?;
|
||||
imap_conn.logout();
|
||||
return Ok(());
|
||||
}
|
||||
@@ -304,7 +305,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
if let Some(matches) = matches.subcommand_matches("template") {
|
||||
if let Some(_) = matches.subcommand_matches("new") {
|
||||
let tpl = Msg::build_new_tpl(&config, &account)?;
|
||||
print(&output_fmt, &tpl)?;
|
||||
print(&output_fmt, &silent, &tpl)?;
|
||||
}
|
||||
|
||||
if let Some(matches) = matches.subcommand_matches("reply") {
|
||||
@@ -316,7 +317,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
} else {
|
||||
msg.build_reply_tpl(&config, &account)?
|
||||
};
|
||||
print(&output_fmt, &tpl)?;
|
||||
print(&output_fmt, &silent, &tpl)?;
|
||||
imap_conn.logout();
|
||||
}
|
||||
|
||||
@@ -325,7 +326,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
let uid = matches.value_of("uid").unwrap();
|
||||
let msg = Msg::from(imap_conn.read_msg(&mbox, &uid)?);
|
||||
let tpl = msg.build_forward_tpl(&config, &account)?;
|
||||
print(&output_fmt, &tpl)?;
|
||||
print(&output_fmt, &silent, &tpl)?;
|
||||
imap_conn.logout();
|
||||
}
|
||||
|
||||
@@ -440,6 +441,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
|
||||
print(
|
||||
&output_fmt,
|
||||
&silent,
|
||||
Info(format!(
|
||||
"Message {} successfully copied to folder `{}`",
|
||||
&uid, &target
|
||||
@@ -461,6 +463,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
|
||||
print(
|
||||
&output_fmt,
|
||||
&silent,
|
||||
Info(format!(
|
||||
"Message {} successfully moved to folder `{}`",
|
||||
&uid, &target
|
||||
@@ -477,6 +480,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
|
||||
print(
|
||||
&output_fmt,
|
||||
&silent,
|
||||
Info(format!("Message {} successfully deleted", &uid)),
|
||||
)?;
|
||||
return Ok(());
|
||||
@@ -506,7 +510,7 @@ pub fn msg_matches(matches: &ArgMatches) -> Result<()> {
|
||||
let mut imap_conn = ImapConnector::new(&account)?;
|
||||
let msgs = imap_conn.list_msgs(&mbox, &10, &0)?;
|
||||
let msgs = Msgs::from(&msgs);
|
||||
print(&output_fmt, msgs)?;
|
||||
print(&output_fmt, &silent, msgs)?;
|
||||
imap_conn.logout();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user