[monitoring-plugin-perl] Move Getopt param/reqd defs into dedicated hash
Tom Ryder
git at monitoring-plugins.org
Fri Dec 22 11:50:07 CET 2017
Module: monitoring-plugin-perl
Branch: master
Commit: c1046bab2e6681f5e4714178d6cc1cd16f067382
Author: Tom Ryder <tom at sanctum.geek.nz>
Date: Sat Dec 16 13:02:34 2017 +1300
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugin-perl/commit/?id=c1046ba
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
More information about the Commits
mailing list