From ee3aaa017f34b4f851272dd58db6d37b3ace9993 Mon Sep 17 00:00:00 2001 From: Nathan Ross Date: Sun, 14 Aug 2016 22:49:27 -0400 Subject: [PATCH] uucore: allow 'wrong number of arguments' macro to be more precise --- src/uucore/macros.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/uucore/macros.rs b/src/uucore/macros.rs index a88d78b84..5e2f68a66 100644 --- a/src/uucore/macros.rs +++ b/src/uucore/macros.rs @@ -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)));} #[macro_export] -macro_rules! msg_wrong_number_of_arguments { () => ( - msg_args_invalid_value!("wrong number of arguments") ); } +macro_rules! msg_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