summaryrefslogtreecommitdiffstats
path: root/lib/Monitoring/Plugin/Getopt.pm
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-12-16 13:25:34 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-12-16 13:25:34 +1300
commitc3f2a7cd7313868166ba205e9eff2b8be6a36ea4 (patch)
tree018986888d2b8bee072c0341c62f126c5aa860f0 /lib/Monitoring/Plugin/Getopt.pm
parent40d5fbea30c310004233ef4cd3e570c351c54233 (diff)
downloadmonitoring-plugin-perl-c3f2a7cd7313868166ba205e9eff2b8be6a36ea4.tar.gz
Refactor positional arg parsing for Getopt::arg()
Define the expected order of parameters by key in an array, and then apply hash slices to validate and assign the arguments including their required flags in one swoop, again hinging on the parameter definitions established in c1046ba.
Diffstat (limited to 'lib/Monitoring/Plugin/Getopt.pm')
-rw-r--r--lib/Monitoring/Plugin/Getopt.pm10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/Monitoring/Plugin/Getopt.pm b/lib/Monitoring/Plugin/Getopt.pm
index feee002..048b0ef 100644
--- a/lib/Monitoring/Plugin/Getopt.pm
+++ b/lib/Monitoring/Plugin/Getopt.pm
@@ -398,14 +398,8 @@ sub arg
398 398
399 # Positional args 399 # Positional args
400 else { 400 else {
401 my @args = validate_pos(@_, 1, 1, 0, 0, 0); 401 my @order = qw(spec help default required label);
402 %args = ( 402 @args{@order} = validate_pos(@_, @params{@order});
403 spec => $args[0],
404 help => $args[1],
405 default => $args[2],
406 required => $args[3],
407 label => $args[4],
408 );
409 } 403 }
410 404
411 # Add to private args arrayref 405 # Add to private args arrayref