diff options
Diffstat (limited to 'lib/Monitoring')
-rw-r--r-- | lib/Monitoring/Plugin/Getopt.pm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Monitoring/Plugin/Getopt.pm b/lib/Monitoring/Plugin/Getopt.pm index 106600a..9452058 100644 --- a/lib/Monitoring/Plugin/Getopt.pm +++ b/lib/Monitoring/Plugin/Getopt.pm | |||
@@ -81,14 +81,15 @@ sub _spec_to_help | |||
81 | { | 81 | { |
82 | my ($self, $spec, $label) = @_; | 82 | my ($self, $spec, $label) = @_; |
83 | 83 | ||
84 | my ($opts, $type) = split /=|:/, $spec, 2; | 84 | my ($opts, $type) = split /=|:|!/, $spec, 2; |
85 | my $optional = ($spec =~ m/:/); | 85 | my $optional = ($spec =~ m/:/); |
86 | my $boolean = ($spec =~ m/!/); | ||
86 | my (@short, @long); | 87 | my (@short, @long); |
87 | for (split /\|/, $opts) { | 88 | for (split /\|/, $opts) { |
88 | if (length $_ == 1) { | 89 | if (length $_ == 1) { |
89 | push @short, "-$_"; | 90 | push @short, "-$_"; |
90 | } else { | 91 | } else { |
91 | push @long, "--$_"; | 92 | push @long, $boolean ? "--[no-]$_" : "--$_"; |
92 | } | 93 | } |
93 | } | 94 | } |
94 | 95 | ||
@@ -207,7 +208,7 @@ sub _process_specs_getopt_long | |||
207 | # Setup names and defaults | 208 | # Setup names and defaults |
208 | my $spec = $arg->{spec}; | 209 | my $spec = $arg->{spec}; |
209 | # Use first arg as name (like Getopt::Long does) | 210 | # Use first arg as name (like Getopt::Long does) |
210 | $spec =~ s/[=:].*$//; | 211 | $spec =~ s/[=:!].*$//; |
211 | my $name = (split /\s*\|\s*/, $spec)[0]; | 212 | my $name = (split /\s*\|\s*/, $spec)[0]; |
212 | $arg->{name} = $name; | 213 | $arg->{name} = $name; |
213 | if (defined $self->{$name}) { | 214 | if (defined $self->{$name}) { |
@@ -697,7 +698,8 @@ but basically it is a series of one or more argument names for this argument | |||
697 | (separated by '|'), suffixed with an '=<type>' indicator if the argument | 698 | (separated by '|'), suffixed with an '=<type>' indicator if the argument |
698 | takes a value. '=s' indicates a string argument; '=i' indicates an integer | 699 | takes a value. '=s' indicates a string argument; '=i' indicates an integer |
699 | argument; appending an '@' indicates multiple such arguments are accepted; | 700 | argument; appending an '@' indicates multiple such arguments are accepted; |
700 | and so on. The following are some examples: | 701 | appending an '!' indicates negation using '--no'-prefix is possible; and so on. |
702 | The following are some examples: | ||
701 | 703 | ||
702 | =over 4 | 704 | =over 4 |
703 | 705 | ||
@@ -709,6 +711,8 @@ and so on. The following are some examples: | |||
709 | 711 | ||
710 | =item exclude|X=s@ | 712 | =item exclude|X=s@ |
711 | 713 | ||
714 | =item perfdata! | ||
715 | |||
712 | =item verbose|v+ | 716 | =item verbose|v+ |
713 | 717 | ||
714 | =back | 718 | =back |