Skip to content

Commit

Permalink
Simplify connection type option check
Browse files Browse the repository at this point in the history
  • Loading branch information
tmknight committed Dec 11, 2024
1 parent b75af60 commit 8d4fa38
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/inquire/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ pub fn get_opts(args: Vec<String>) -> OptionsList {
"<TCP_TIMEOUT>",
);
opts.optopt("w", "webhook-url", "The webhook url", "<WEBHOOK_URL>");
opts.optflag("L", "log-persist", "Enable external logging and reporting of historical data");
opts.optflag(
"L",
"log-persist",
"Enable external logging and reporting of historical data",
);
opts.optopt(
"P",
"post-action",
Expand Down Expand Up @@ -119,20 +123,17 @@ pub fn get_opts(args: Vec<String>) -> OptionsList {
}

// Ensure acceptable connection type arguments
match matches.opt_str("c").is_some() {
true => {
let opt_connection_type = matches.opt_str("c").unwrap();
match ALLOWED_CONNECTION_TYPES.contains(&opt_connection_type.as_str()) {
true => {}
false => {
println!("Unexpected connection-type: {}", opt_connection_type);
println!("{}", opts.usage(&program));
std::process::exit(1);
}
if matches.opt_str("c").is_some() {
let opt_connection_type = matches.opt_str("c").unwrap();
match ALLOWED_CONNECTION_TYPES.contains(&opt_connection_type.as_str()) {
true => {}
false => {
println!("Unexpected connection-type: {}", opt_connection_type);
println!("{}", opts.usage(&program));
std::process::exit(1);
}
}
false => {}
};
}

OptionsList {
apprise_url: matches.opt_str("a"),
Expand Down

0 comments on commit 8d4fa38

Please sign in to comment.