Add macro for checking if modifiers were entered & panic through clap

pull/4/head
sgoudham 3 years ago
parent c27ce62b97
commit 45b864f5ea

@ -1,3 +1,5 @@
use std::panic::set_hook;
use clap::{Arg, ArgGroup, ErrorKind};
use uwuifyy::UwUify;
@ -99,13 +101,16 @@ macro_rules! clap_panic {
};
}
macro_rules! is_runtime {
($faces:expr, $actions:expr, $stutters:expr) => {
$faces > 0 || $actions > 0 || $stutters > 0
};
}
fn main() {
std::panic::set_hook(Box::new(|info| {
clap_panic!(info);
}));
let matches = app!().get_matches();
set_hook(Box::new(|info| clap_panic!(info)));
// panicing here ensures that the error is passed to the hook above instead of to stdout.
let matches = app!().get_matches();
match UwUify::new(
matches.value_of("text"),
matches.value_of("infile"),
@ -115,10 +120,15 @@ fn main() {
matches.value_of("actions"),
matches.value_of("stutters"),
matches.is_present("random"),
is_runtime!(
matches.occurrences_of("faces"),
matches.occurrences_of("actions"),
matches.occurrences_of("stutters")
),
)
.uwuify()
{
Err(e) => clap_panic!(e),
Err(err) => clap_panic!(err),
_ => {}
};
}

Loading…
Cancel
Save