use clap::Parser; #[derive(Parser, Debug)] pub struct CliArgs { // TODO: switch default sever uri to real one when we get one /// Upstream server to use #[clap( short, long, value_parser, default_value = "https://fixme.communiquons.org" )] pub server_uri: String, /// Local server listen address #[clap(short, long, default_value = "127.0.0.1:5679")] pub listen_address: String, } impl CliArgs { /// Get local listen port pub fn listen_port(&self) -> u16 { self.listen_address .rsplit(':') .next() .expect("Failed to split listen address!") .parse::() .expect("Failed to parse listen port!") } } lazy_static::lazy_static! { static ref ARGS: CliArgs = { CliArgs::parse() }; } /// Get parsed command line arguments pub fn cli_args() -> &'static CliArgs { &ARGS }