summaryrefslogtreecommitdiffstats
path: root/lib/Monitoring/Plugin/Getopt.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Monitoring/Plugin/Getopt.pm')
-rw-r--r--lib/Monitoring/Plugin/Getopt.pm29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/Monitoring/Plugin/Getopt.pm b/lib/Monitoring/Plugin/Getopt.pm
index 262e3c8..c8033d0 100644
--- a/lib/Monitoring/Plugin/Getopt.pm
+++ b/lib/Monitoring/Plugin/Getopt.pm
@@ -382,27 +382,24 @@ sub arg
382 my $self = shift; 382 my $self = shift;
383 my %args; 383 my %args;
384 384
385 # Named args 385 # Param name to required boolean
386 if ($_[0] =~ m/^(spec|help|required|default|label)$/ && scalar(@_) % 2 == 0) { 386 my %params = (
387 %args = validate( @_, { 387 spec => 1,
388 spec => 1, 388 help => 1,
389 help => 1, 389 default => 0,
390 default => 0,
391 required => 0, 390 required => 0,
392 label => 0, 391 label => 0,
393 }); 392 );
393
394 # Named args
395 if (exists $params{$_[0]} && @_ % 2 == 0) {
396 %args = validate( @_, \%params );
394 } 397 }
395 398
396 # Positional args 399 # Positional args
397 else { 400 else {
398 my @args = validate_pos(@_, 1, 1, 0, 0, 0); 401 my @order = qw(spec help default required label);
399 %args = ( 402 @args{@order} = validate_pos(@_, @params{@order});
400 spec => $args[0],
401 help => $args[1],
402 default => $args[2],
403 required => $args[3],
404 label => $args[4],
405 );
406 } 403 }
407 404
408 # Add to private args arrayref 405 # Add to private args arrayref