+ add some code in core to display help with fatpacker build
This commit is contained in:
parent
0cf9a0160b
commit
952c293c44
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# Copyright 2016 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package centreon::plugins::alternative::FatPackerOptions;
|
||||
|
||||
use base qw(centreon::plugins::options);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Pod::Usage;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub display_help {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout;
|
||||
foreach (@{$self->{pod_package}}) {
|
||||
|
||||
{
|
||||
my $pp = $_->{package} . ".pm";
|
||||
$pp =~ s{::}{/}g;
|
||||
my $content_class = $INC{$pp}->{$pp};
|
||||
open my $str_fh, '<', \$content_class;
|
||||
|
||||
local *STDOUT;
|
||||
open STDOUT, '>', \$stdout;
|
||||
pod2usage(-exitval => 'NOEXIT', -input => $str_fh,
|
||||
-verbose => 99,
|
||||
-sections => $_->{sections});
|
||||
|
||||
close $str_fh;
|
||||
}
|
||||
|
||||
$self->{output}->add_option_msg(long_msg => $stdout) if (defined($stdout));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
|
@ -22,7 +22,6 @@ package centreon::plugins::script;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::options;
|
||||
use centreon::plugins::output;
|
||||
use centreon::plugins::misc;
|
||||
use FindBin;
|
||||
|
@ -32,6 +31,7 @@ use Pod::Find qw(pod_where);
|
|||
my %handlers = (DIE => {});
|
||||
|
||||
my $global_version = 20160217;
|
||||
my $alternative_fatpacker = 0;
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
@ -84,7 +84,13 @@ sub get_plugin {
|
|||
######
|
||||
# Need to load global 'Output' and 'Options'
|
||||
######
|
||||
$self->{options} = centreon::plugins::options->new();
|
||||
if ($alternative_fatpacker == 0) {
|
||||
require centreon::plugins::options;
|
||||
$self->{options} = centreon::plugins::options->new();
|
||||
} else {
|
||||
require centreon::plugins::alternative::FatPackerOptions;
|
||||
$self->{options} = centreon::plugins::alternative::FatPackerOptions->new();
|
||||
}
|
||||
$self->{output} = centreon::plugins::output->new(options => $self->{options});
|
||||
$self->{options}->set_output(output => $self->{output});
|
||||
|
||||
|
@ -122,7 +128,17 @@ sub display_local_help {
|
|||
if ($self->{help}) {
|
||||
local *STDOUT;
|
||||
open STDOUT, '>', \$stdout;
|
||||
pod2usage(-exitval => "NOEXIT", -input => pod_where({-inc => 1}, __PACKAGE__));
|
||||
|
||||
if ($alternative_fatpacker == 0) {
|
||||
pod2usage(-exitval => "NOEXIT", -input => pod_where({-inc => 1}, __PACKAGE__));
|
||||
} else {
|
||||
my $pp = __PACKAGE__ . ".pm";
|
||||
$pp =~ s{::}{/}g;
|
||||
my $content_class = $INC{$pp}->{$pp};
|
||||
open my $str_fh, '<', \$content_class;
|
||||
pod2usage(-exitval => "NOEXIT", -input => $str_fh);
|
||||
close $str_fh;
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->add_option_msg(long_msg => $stdout) if (defined($stdout));
|
||||
|
|
Loading…
Reference in New Issue