1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-05 07:27:46 +00:00

uucore: allow 'wrong number of arguments' macro to be more precise

This commit is contained in:
Nathan Ross 2016-08-14 22:49:27 -04:00 committed by Roy Ivy III
parent 8cb2edecb1
commit 22fab1444e

View file

@ -327,8 +327,21 @@ macro_rules! msg_args_nonexistent_file { ($received:expr) => (
msg_args_invalid_value!("paths to files", snippet_no_file_at_path!($received)));} msg_args_invalid_value!("paths to files", snippet_no_file_at_path!($received)));}
#[macro_export] #[macro_export]
macro_rules! msg_wrong_number_of_arguments { () => ( macro_rules! msg_wrong_number_of_arguments {
msg_args_invalid_value!("wrong number of arguments") ); } () => (
msg_args_invalid_value!("wrong number of arguments")
);
($min:expr, $max:expr) => (
msg_args_invalid_value!(format!("expects {}-{} arguments", $min, $max))
);
($exact:expr) => (
if $exact == 1 {
msg_args_invalid_value!("expects 1 argument")
} else {
msg_args_invalid_value!(format!("expects {} arguments", $exact))
}
);
}
// -- message templates : invalid input : input combinations // -- message templates : invalid input : input combinations