diff --git a/Cargo.toml b/Cargo.toml index 07990d4..0cc4383 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Maxime “pep” Buquet "] license = "AGPL-3.0+" [dependencies] -clap = { version = "4.3", features = [ "cargo", "derive" ] } +clap = { version = "4.3", features = [ "cargo" ] } gitlab = "0.1511.0" hyper = { version = "0.14", features = [ "full" ] } jid = { version = "*", features = [ "serde" ] } diff --git a/src/main.rs b/src/main.rs index 2c8680b..b07e72e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,23 +33,16 @@ use std::net::{IpAddr, Ipv6Addr, SocketAddr}; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; -use clap::Parser; +use clap::{command, value_parser, Arg}; use hyper::{ service::{make_service_fn, service_fn}, Server, }; +use log::debug; use serde::{Deserialize, Serialize}; use tokio::sync::mpsc; use xmpp_parsers::BareJid; -#[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] -struct Args { - /// Config file path - #[arg(short, long)] - config: Option, -} - #[derive(Debug, Serialize, Deserialize)] struct Config { /// Account address @@ -100,14 +93,23 @@ fn config_from_file(file: PathBuf) -> Result { async fn main() -> Result { pretty_env_logger::init(); - let args = Args::parse(); + let matches = command!() + .arg( + Arg::new("config") + .short('c') + .long("config") + .required(false) + .value_parser(value_parser!(PathBuf)), + ) + .get_matches(); + let config = { - let path = match args.config { + let path = match matches.get_one::("config") { Some(path) => { if !path.starts_with("/") { std::env::current_dir()?.join(path) } else { - path + path.to_path_buf() } } None => { @@ -123,6 +125,8 @@ async fn main() -> Result { } }; + debug!("Using configuration file: {:?}", path); + match config_from_file(path) { Ok(config) => config, Err(err) => return Err(err), diff --git a/src/xmpp.rs b/src/xmpp.rs index 66eb00a..7972c98 100644 --- a/src/xmpp.rs +++ b/src/xmpp.rs @@ -64,6 +64,9 @@ impl XmppClient { .await } } + Event::Disconnected => { + debug!("XMPP Disconnected"); + } _ => { debug!("XMPP Event not supported") }