diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-03-03 16:21:11 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-03-03 16:21:11 +0000 |
commit | 26d529e6faaafa442e2b06093db1714f8f0b75bc (patch) | |
tree | b59b58dad7f815386b05d414cdd7e70ffd00e056 /lib | |
parent | bfaee2787b9e955d0f7231cbc1fa045d6d892d60 (diff) | |
download | mangemanche-26d529e6faaafa442e2b06093db1714f8f0b75bc.tar.gz mangemanche-26d529e6faaafa442e2b06093db1714f8f0b75bc.tar.bz2 |
Rename App/Ping903 to App::Mangemanche
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/Mangemanche.pm (renamed from lib/App/Ping903.pm) | 63 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command.pm (renamed from lib/App/Ping903/Command.pm) | 2 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/dbload.pm (renamed from lib/App/Ping903/Command/dbload.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ident.pm (renamed from lib/App/Ping903/Command/ident.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/inspect.pm (renamed from lib/App/Ping903/Command/inspect.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ipadd.pm (renamed from lib/App/Ping903/Command/ipadd.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/ipdel.pm (renamed from lib/App/Ping903/Command/ipdel.pm) | 6 | ||||
-rw-r--r-- | lib/App/Mangemanche/Command/nagios.pm (renamed from lib/App/Ping903/Command/nagios.pm) | 51 |
8 files changed, 123 insertions, 23 deletions
diff --git a/lib/App/Ping903.pm b/lib/App/Mangemanche.pm index 2a39391..d719ecb 100644 --- a/lib/App/Ping903.pm +++ b/lib/App/Mangemanche.pm | |||
@@ -1,4 +1,4 @@ | |||
1 | package App::Ping903; | 1 | package App::Mangemanche; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order); | 4 | use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order); |
@@ -6,7 +6,7 @@ use Pod::Man; | |||
6 | use Pod::Usage; | 6 | use Pod::Usage; |
7 | use Pod::Find qw(pod_where); | 7 | use Pod::Find qw(pod_where); |
8 | use Net::Ping903; | 8 | use Net::Ping903; |
9 | use App::Ping903::Command ':exit_codes'; | 9 | use App::Mangemanche::Command ':exit_codes'; |
10 | use File::Basename; | 10 | use File::Basename; |
11 | 11 | ||
12 | our $VERSION = '0.4.90'; | 12 | our $VERSION = '0.4.90'; |
@@ -24,10 +24,12 @@ sub new { | |||
24 | pod2usage(-input => pod_where({-inc => 1}, $class), | 24 | pod2usage(-input => pod_where({-inc => 1}, $class), |
25 | -verbose => 99, | 25 | -verbose => 99, |
26 | -sections => [qw(NAME SYNOPSIS COMMANDS)], | 26 | -sections => [qw(NAME SYNOPSIS COMMANDS)], |
27 | -exitstatus => EX_OK) | 27 | -exitstatus => 'NOEXIT'); |
28 | $class->list_commands; | ||
29 | exit(EX_OK); | ||
28 | }, | 30 | }, |
29 | 'help' => sub { | 31 | 'help' => sub { |
30 | App::Ping903::Command::mandoc($class, basename($0)), | 32 | App::Mangemanche::Command::mandoc($class, basename($0)), |
31 | }, | 33 | }, |
32 | 'usage' => sub { | 34 | 'usage' => sub { |
33 | pod2usage(-exitstatus => EX_OK, | 35 | pod2usage(-exitstatus => EX_OK, |
@@ -105,12 +107,65 @@ sub readconfig { | |||
105 | return $config; | 107 | return $config; |
106 | } | 108 | } |
107 | 109 | ||
110 | sub list_commands { | ||
111 | my $class = shift; | ||
112 | my @classpath = (split(/::/, $class), 'Command'); | ||
113 | |||
114 | print "\nAvailable commands are:\n"; | ||
115 | foreach my $mod (sort | ||
116 | map { | ||
117 | my $name = basename($_); | ||
118 | if (exists($INC{File::Spec->catfile(@classpath,$name)})) { | ||
119 | () | ||
120 | } else { | ||
121 | eval { | ||
122 | require $_; | ||
123 | }; | ||
124 | $name =~ s/\.pm$//; | ||
125 | $@ ? () : [$name, $_]; | ||
126 | } | ||
127 | } | ||
128 | map { | ||
129 | glob File::Spec->catfile($_, @classpath, '*.pm') | ||
130 | } @INC) { | ||
131 | |||
132 | my $s; | ||
133 | open(my $fh, '>', \$s); | ||
134 | pod2usage(-input => $mod->[1], | ||
135 | -output => $fh, | ||
136 | -verbose => 99, | ||
137 | -sections => ['NAME'], | ||
138 | -exitstatus => 'NOEXIT'); | ||
139 | close $fh; | ||
140 | my (undef, $descr) = split("\n", $s||''); | ||
141 | unless ($descr) { | ||
142 | $descr = ' ' . $mod->[0] | ||
143 | } | ||
144 | print "$descr\n"; | ||
145 | } | ||
146 | } | ||
147 | |||
108 | 1; | 148 | 1; |
109 | 149 | ||
110 | =head1 NAME | 150 | =head1 NAME |
111 | 151 | ||
152 | mangemanche - interface to B<ping903> daemon. | ||
153 | |||
112 | =head1 SYNOPSIS | 154 | =head1 SYNOPSIS |
113 | 155 | ||
156 | B<mangemanche> | ||
157 | [B<-c> I<FILE>] | ||
158 | [B<-u> I<FILE>] | ||
159 | [B<--config=>I<FILE>] | ||
160 | [B<--url=>I<FILE>] | ||
161 | I<COMMAND> | ||
162 | I<ARG>... | ||
163 | |||
164 | B<mangemanche> | ||
165 | [B<-?>] | ||
166 | [B<--help>] | ||
167 | [B<--usage>] | ||
168 | |||
114 | =head1 DESCRIPTION | 169 | =head1 DESCRIPTION |
115 | 170 | ||
116 | =head1 OPTIONS | 171 | =head1 OPTIONS |
diff --git a/lib/App/Ping903/Command.pm b/lib/App/Mangemanche/Command.pm index bd1a85f..9857652 100644 --- a/lib/App/Ping903/Command.pm +++ b/lib/App/Mangemanche/Command.pm | |||
@@ -1,4 +1,4 @@ | |||
1 | package App::Ping903::Command; | 1 | package App::Mangemanche::Command; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use Getopt::Long; | 4 | use Getopt::Long; |
diff --git a/lib/App/Ping903/Command/dbload.pm b/lib/App/Mangemanche/Command/dbload.pm index 20c8ad1..c7ddf38 100644 --- a/lib/App/Ping903/Command/dbload.pm +++ b/lib/App/Mangemanche/Command/dbload.pm | |||
@@ -1,8 +1,8 @@ | |||
1 | package App::Ping903::Command::dbload; | 1 | package App::Mangemanche::Command::dbload; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use parent 'App::Ping903::Command'; | 4 | use parent 'App::Mangemanche::Command'; |
5 | use App::Ping903::Command ':exit_codes'; | 5 | use App::Mangemanche::Command ':exit_codes'; |
6 | use JSON; | 6 | use JSON; |
7 | use DBI; | 7 | use DBI; |
8 | use File::Spec; | 8 | use File::Spec; |
diff --git a/lib/App/Ping903/Command/ident.pm b/lib/App/Mangemanche/Command/ident.pm index 67cebd9..a871b95 100644 --- a/lib/App/Ping903/Command/ident.pm +++ b/lib/App/Mangemanche/Command/ident.pm | |||
@@ -1,8 +1,8 @@ | |||
1 | package App::Ping903::Command::ident; | 1 | package App::Mangemanche::Command::ident; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use parent 'App::Ping903::Command'; | 4 | use parent 'App::Mangemanche::Command'; |
5 | use App::Ping903::Command ':exit_codes'; | 5 | use App::Mangemanche::Command ':exit_codes'; |
6 | 6 | ||
7 | sub run { | 7 | sub run { |
8 | my $self = shift; | 8 | my $self = shift; |
diff --git a/lib/App/Ping903/Command/inspect.pm b/lib/App/Mangemanche/Command/inspect.pm index 6c4a11b..81f1049 100644 --- a/lib/App/Ping903/Command/inspect.pm +++ b/lib/App/Mangemanche/Command/inspect.pm | |||
@@ -1,8 +1,8 @@ | |||
1 | package App::Ping903::Command::inspect; | 1 | package App::Mangemanche::Command::inspect; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use parent 'App::Ping903::Command'; | 4 | use parent 'App::Mangemanche::Command'; |
5 | use App::Ping903::Command ':exit_codes'; | 5 | use App::Mangemanche::Command ':exit_codes'; |
6 | 6 | ||
7 | sub run { | 7 | sub run { |
8 | my $self = shift; | 8 | my $self = shift; |
diff --git a/lib/App/Ping903/Command/ipadd.pm b/lib/App/Mangemanche/Command/ipadd.pm index 443c052..53c48b6 100644 --- a/lib/App/Ping903/Command/ipadd.pm +++ b/lib/App/Mangemanche/Command/ipadd.pm | |||
@@ -1,8 +1,8 @@ | |||
1 | package App::Ping903::Command::ipadd; | 1 | package App::Mangemanche::Command::ipadd; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use parent 'App::Ping903::Command'; | 4 | use parent 'App::Mangemanche::Command'; |
5 | use App::Ping903::Command ':exit_codes'; | 5 | use App::Mangemanche::Command ':exit_codes'; |
6 | 6 | ||
7 | sub run { | 7 | sub run { |
8 | my $self = shift; | 8 | my $self = shift; |
diff --git a/lib/App/Ping903/Command/ipdel.pm b/lib/App/Mangemanche/Command/ipdel.pm index 45ca0d7..ef4005b 100644 --- a/lib/App/Ping903/Command/ipdel.pm +++ b/lib/App/Mangemanche/Command/ipdel.pm | |||
@@ -1,8 +1,8 @@ | |||
1 | package App::Ping903::Command::ipdel; | 1 | package App::Mangemanche::Command::ipdel; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use parent 'App::Ping903::Command'; | 4 | use parent 'App::Mangemanche::Command'; |
5 | use App::Ping903::Command ':exit_codes'; | 5 | use App::Mangemanche::Command ':exit_codes'; |
6 | 6 | ||
7 | sub run { | 7 | sub run { |
8 | my $self = shift; | 8 | my $self = shift; |
diff --git a/lib/App/Ping903/Command/nagios.pm b/lib/App/Mangemanche/Command/nagios.pm index b6c8204..7e42d01 100644 --- a/lib/App/Ping903/Command/nagios.pm +++ b/lib/App/Mangemanche/Command/nagios.pm | |||
@@ -1,8 +1,8 @@ | |||
1 | package App::Ping903::Command::nagios; | 1 | package App::Mangemanche::Command::nagios; |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use parent 'App::Ping903::Command'; | 4 |