summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-08-31 08:34:24 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-08-31 08:34:24 (GMT)
commitf2aa8f510828ddfb165f84ecc13aaf29d7bdfb4d (patch)
treeb5445def675470d2eae0d61ed159b3b59b3dae11
parent2b422c372ee109303984ca8bac6f5ea3d5976dc0 (diff)
downloadmonitoring-plugin-perl-f2aa8f510828ddfb165f84ecc13aaf29d7bdfb4d.tar.gz
Support multiple -v options for verbosity level
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1472 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--lib/Nagios/Plugin/Getopt.pm8
-rw-r--r--t/Nagios-Plugin-Getopt-01.t13
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/Nagios/Plugin/Getopt.pm b/lib/Nagios/Plugin/Getopt.pm
index d291b2f..1903e8c 100644
--- a/lib/Nagios/Plugin/Getopt.pm
+++ b/lib/Nagios/Plugin/Getopt.pm
@@ -41,8 +41,8 @@ my @ARGS = ({
41 help => "-t, --timeout=INTEGER\n Seconds before plugin times out (default: %s)", 41 help => "-t, --timeout=INTEGER\n Seconds before plugin times out (default: %s)",
42 default => $DEFAULT{timeout}, 42 default => $DEFAULT{timeout},
43 }, { 43 }, {
44 spec => 'verbose|v', 44 spec => 'verbose|v+',
45 help => "-v, --verbose\n Show details for command-line debugging", 45 help => "-v, --verbose\n Show details for command-line debugging (can repeat up to 3 times)",
46 default => $DEFAULT{verbose}, 46 default => $DEFAULT{verbose},
47 }, 47 },
48); 48);
@@ -467,7 +467,7 @@ example:
467 -t, --timeout=INTEGER 467 -t, --timeout=INTEGER
468 Seconds before plugin times out (default: 15) 468 Seconds before plugin times out (default: 15)
469 -v, --verbose 469 -v, --verbose
470 Show details for command-line debugging 470 Show details for command-line debugging (can repeat up to 3 times)
471 471
472 472
473=head2 ARGUMENTS 473=head2 ARGUMENTS
@@ -506,7 +506,7 @@ and so on. The following are some examples:
506 506
507=item exclude|X=s@ 507=item exclude|X=s@
508 508
509=item verbose|v 509=item verbose|v+
510 510
511=back 511=back
512 512
diff --git a/t/Nagios-Plugin-Getopt-01.t b/t/Nagios-Plugin-Getopt-01.t
index fad68e3..b708a5f 100644
--- a/t/Nagios-Plugin-Getopt-01.t
+++ b/t/Nagios-Plugin-Getopt-01.t
@@ -2,7 +2,7 @@
2 2
3use strict; 3use strict;
4 4
5use Test::More tests => 72; 5use Test::More tests => 76;
6BEGIN { use_ok('Nagios::Plugin::Getopt') }; 6BEGIN { use_ok('Nagios::Plugin::Getopt') };
7 7
8my %PARAM = ( 8my %PARAM = (
@@ -45,6 +45,17 @@ is($ng->warning, 3, 'warning set to 3');
45is($ng->critical, 10, 'critical set to 10'); 45is($ng->critical, 10, 'critical set to 10');
46is($ng->timeout, 12, 'timeout set to 12'); 46is($ng->timeout, 12, 'timeout set to 12');
47 47
48# Check multiple verbose flags
49@ARGV = qw(-w 3 --critical 10 -v -v -v);
50$ng = setup;
51$ng->getopts;
52is ($ng->verbose, 3, "Verbose set to level 3");
53
54@ARGV = qw(-w 3 --critical 10 --verbose --verbose --verbose);
55$ng = setup;
56$ng->getopts;
57is ($ng->verbose, 3, "Verbose set to level 3 (longhand)");
58
48# Missing args 59# Missing args
49@ARGV = qw(); 60@ARGV = qw();
50$ng = setup; 61$ng = setup;