aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd/watch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/watch.rs')
-rw-r--r--src/cmd/watch.rs34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs
index f9fc7c3..f73457e 100644
--- a/src/cmd/watch.rs
+++ b/src/cmd/watch.rs
@@ -15,17 +15,20 @@ impl crate::config::Config for Config {
self.client.merge_args(matches)
}
- fn run(&self) -> Result<()> {
- let host = self.client.host().to_string();
- let address = *self.client.addr();
+ fn run(
+ &self,
+ ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send> {
let auth = match self.client.auth {
crate::protocol::AuthType::Plain => {
let username = self
.client
.username
.clone()
- .context(crate::error::CouldntFindUsername)?;
- crate::protocol::Auth::plain(&username)
+ .context(crate::error::CouldntFindUsername);
+ match username {
+ Ok(username) => crate::protocol::Auth::plain(&username),
+ Err(e) => return Box::new(futures::future::err(e)),
+ }
}
crate::protocol::AuthType::RecurseCenter => {
let id = crate::oauth::load_client_auth_id(self.client.auth);
@@ -34,11 +37,16 @@ impl crate::config::Config for Config {
)
}
};
- let fut: Box<
- dyn futures::future::Future<Item = (), Error = Error> + Send,
- > = if self.client.tls {
- let connector = native_tls::TlsConnector::new()
- .context(crate::error::CreateConnector)?;
+
+ let host = self.client.host().to_string();
+ let address = *self.client.addr();
+ if self.client.tls {
+ let connector = match native_tls::TlsConnector::new()
+ .context(crate::error::CreateConnector)
+ {
+ Ok(connector) => connector,
+ Err(e) => return Box::new(futures::future::err(e)),
+ };
let make_connector: Box<
dyn Fn() -> crate::client::Connector<_> + Send,
> = Box::new(move || {
@@ -74,11 +82,7 @@ impl crate::config::Config for Config {
})
});
Box::new(WatchSession::new(make_connector, &auth))
- };
- tokio::run(fut.map_err(|e| {
- log::error!("{}", e);
- }));
- Ok(())
+ }
}
}