From c1046bab2e6681f5e4714178d6cc1cd16f067382 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 16 Dec 2017 13:02:34 +1300 Subject: Move Getopt param/reqd defs into dedicated hash This shift and its comment makes what the values of the hashref passed to the validate() methods mean clearer, and also allows the use of the keys as a means of determining whether arg() was passed its definition in the array or hash format in a separate commit. --- lib/Monitoring/Plugin/Getopt.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/Monitoring/Plugin/Getopt.pm b/lib/Monitoring/Plugin/Getopt.pm index 262e3c8..ca1cb61 100644 --- a/lib/Monitoring/Plugin/Getopt.pm +++ b/lib/Monitoring/Plugin/Getopt.pm @@ -382,15 +382,18 @@ sub arg my $self = shift; my %args; + # Param name to required boolean + my %params = ( + spec => 1, + help => 1, + default => 0, + required => 0, + label => 0, + ); + # Named args if ($_[0] =~ m/^(spec|help|required|default|label)$/ && scalar(@_) % 2 == 0) { - %args = validate( @_, { - spec => 1, - help => 1, - default => 0, - required => 0, - label => 0, - }); + %args = validate( @_, { %params }); } # Positional args -- cgit v1.2.3-74-g34f1