2022-10-01 17:25:41 +00:00
|
|
|
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"
|
|
|
|
)]
|
2022-10-01 18:44:01 +00:00
|
|
|
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::<u16>()
|
|
|
|
.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
|
2022-10-01 17:25:41 +00:00
|
|
|
}
|