prometheus_wireguard_exporter/src/options.rs

28 lines
1 KiB
Rust
Raw Normal View History

2019-04-23 23:06:35 +02:00
#[derive(Debug, Clone)]
pub(crate) struct Options {
pub verbose: bool,
2019-07-11 15:31:25 +02:00
pub separate_allowed_ips: bool,
2019-05-17 19:32:35 +02:00
pub extract_names_config_file: Option<String>,
pub export_remote_ip_and_port: bool,
2019-04-23 23:06:35 +02:00
}
impl Options {
pub fn from_claps(matches: &clap::ArgMatches<'_>) -> Options {
2019-05-17 19:32:35 +02:00
if let Some(e) = matches.value_of("extract_names_config_file") {
Options {
verbose: matches.is_present("verbose"),
2019-07-11 15:31:25 +02:00
separate_allowed_ips: matches.is_present("separate_allowed_ips"),
2019-05-17 19:32:35 +02:00
extract_names_config_file: Some(e.to_owned()),
export_remote_ip_and_port: matches.is_present("export_remote_ip_and_port"),
2019-05-17 19:32:35 +02:00
}
} else {
Options {
verbose: matches.is_present("verbose"),
2019-07-11 15:31:25 +02:00
separate_allowed_ips: matches.is_present("separate_allowed_ips"),
2019-05-17 19:32:35 +02:00
extract_names_config_file: None,
export_remote_ip_and_port: matches.is_present("export_remote_ip_and_port"),
2019-05-17 19:32:35 +02:00
}
2019-04-23 23:06:35 +02:00
}
}
}