From fa08591162709ad3ea50853319cf9d714be35e87 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 15 Jul 2017 22:35:50 +0200 Subject: [PATCH] echo_bot: take jid, password from cmdline args --- examples/echo_bot.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/echo_bot.rs b/examples/echo_bot.rs index 7f27cfa..ee99250 100644 --- a/examples/echo_bot.rs +++ b/examples/echo_bot.rs @@ -4,15 +4,25 @@ extern crate tokio_xmpp; extern crate jid; extern crate xml; +use std::env::args; +use std::process::exit; use tokio_core::reactor::Core; use futures::{Future, Stream, Sink, future}; use tokio_xmpp::Client; fn main() { - // Tokio_core context + let args: Vec = args().collect(); + if args.len() != 3 { + println!("Usage: {} ", args[0]); + exit(1); + } + let jid = &args[1]; + let password = &args[2]; + + // tokio_core context let mut core = Core::new().unwrap(); // Client instance - let client = Client::new("astrobot@example.org", "", &core.handle()).unwrap(); + let client = Client::new(jid, password, core.handle()).unwrap(); // Make the two interfaces for sending and receiving independent // of each other so we can move one into a closure.