Add argument parsing

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-05-21 23:40:54 +02:00
parent 0cba90dd68
commit 6074db176a
2 changed files with 18 additions and 1 deletions

View file

@ -7,6 +7,7 @@ authors = ["Maxime “pep” Buquet <pep@bouah.net>"]
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"

View file

@ -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::<WebHook>();
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! {