Files
himalaya/src/imap/cli.rs
T
2021-04-28 00:47:24 +02:00

32 lines
813 B
Rust

use clap;
use error_chain::error_chain;
use log::debug;
use crate::{app::App, imap::model::ImapConnector};
error_chain! {
links {
Config(crate::config::model::Error, crate::config::model::ErrorKind);
Imap(crate::imap::model::Error, crate::imap::model::ErrorKind);
}
}
pub fn imap_subcmds<'a>() -> Vec<clap::App<'a, 'a>> {
vec![clap::SubCommand::with_name("idle").about("Spawns a blocking idle daemon")]
}
pub fn imap_matches(app: &App) -> Result<bool> {
if let Some(_) = app.arg_matches.subcommand_matches("idle") {
debug!("idle command matched");
let mut imap_conn = ImapConnector::new(&app.account)?;
imap_conn.idle(&app.config, &app.mbox)?;
imap_conn.logout();
return Ok(true);
}
debug!("nothing matched");
Ok(false)
}