diff --git a/Cargo.toml b/Cargo.toml index dafcb44..4713035 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ authors = ["Maxime “pep” Buquet "] license = "AGPL-3.0+" [dependencies] +clap = { version = "4.3", features = [ "cargo", "derive" ] } gitlab = "0.1511.0" hyper = { version = "0.14", features = [ "full" ] } log = "0.4" diff --git a/src/main.rs b/src/main.rs index 356d5e5..090d279 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,16 +28,32 @@ use std::convert::Infallible; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; +use clap::Parser; use hyper::{ service::{make_service_fn, service_fn}, Server, }; use tokio::sync::mpsc; +use xmpp_parsers::BareJid; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct Args { + /// Account address + #[arg(short, long)] + jid: BareJid, + + /// Account password + #[arg(short, long)] + password: String, +} #[tokio::main] async fn main() { pretty_env_logger::init(); + let args = Args::parse(); + let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); let (value_tx, mut value_rx) = mpsc::unbounded_channel::(); let value_tx = Arc::new(Mutex::new(value_tx)); @@ -54,7 +70,7 @@ async fn main() { println!("Listening on http://{}", addr); let _join = tokio::spawn(server); - let mut client = XmppClient::new("JID", "PASSWD"); + let mut client = XmppClient::new(&String::from(args.jid), args.password.as_str()); loop { tokio::select! {