aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-03-03 16:21:11 +0000
committerSergey Poznyakoff <gray@gnu.org>2020-03-03 16:21:11 +0000
commit26d529e6faaafa442e2b06093db1714f8f0b75bc (patch)
treeb59b58dad7f815386b05d414cdd7e70ffd00e056 /lib
parentbfaee2787b9e955d0f7231cbc1fa045d6d892d60 (diff)
downloadmangemanche-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 @@
1package App::Ping903; 1package App::Mangemanche;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order); 4use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order);
@@ -6,7 +6,7 @@ use Pod::Man;
6use Pod::Usage; 6use Pod::Usage;
7use Pod::Find qw(pod_where); 7use Pod::Find qw(pod_where);
8use Net::Ping903; 8use Net::Ping903;
9use App::Ping903::Command ':exit_codes'; 9use App::Mangemanche::Command ':exit_codes';
10use File::Basename; 10use File::Basename;
11 11
12our $VERSION = '0.4.90'; 12our $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
110sub 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
1081; 1481;
109 149
110=head1 NAME 150=head1 NAME
111 151
152mangemanche - interface to B<ping903> daemon.
153
112=head1 SYNOPSIS 154=head1 SYNOPSIS
113 155
156B<mangemanche>
157[B<-c> I<FILE>]
158[B<-u> I<FILE>]
159[B<--config=>I<FILE>]
160[B<--url=>I<FILE>]
161I<COMMAND>
162I<ARG>...
163
164B<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 @@
1package App::Ping903::Command; 1package App::Mangemanche::Command;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use Getopt::Long; 4use 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 @@
1package App::Ping903::Command::dbload; 1package App::Mangemanche::Command::dbload;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use parent 'App::Ping903::Command'; 4use parent 'App::Mangemanche::Command';
5use App::Ping903::Command ':exit_codes'; 5use App::Mangemanche::Command ':exit_codes';
6use JSON; 6use JSON;
7use DBI; 7use DBI;
8use File::Spec; 8use 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 @@
1package App::Ping903::Command::ident; 1package App::Mangemanche::Command::ident;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use parent 'App::Ping903::Command'; 4use parent 'App::Mangemanche::Command';
5use App::Ping903::Command ':exit_codes'; 5use App::Mangemanche::Command ':exit_codes';
6 6
7sub run { 7sub 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 @@
1package App::Ping903::Command::inspect; 1package App::Mangemanche::Command::inspect;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use parent 'App::Ping903::Command'; 4use parent 'App::Mangemanche::Command';
5use App::Ping903::Command ':exit_codes'; 5use App::Mangemanche::Command ':exit_codes';
6 6
7sub run { 7sub 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 @@
1package App::Ping903::Command::ipadd; 1package App::Mangemanche::Command::ipadd;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use parent 'App::Ping903::Command'; 4use parent 'App::Mangemanche::Command';
5use App::Ping903::Command ':exit_codes'; 5use App::Mangemanche::Command ':exit_codes';
6 6
7sub run { 7sub 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 @@
1package App::Ping903::Command::ipdel; 1package App::Mangemanche::Command::ipdel;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use parent 'App::Ping903::Command'; 4use parent 'App::Mangemanche::Command';
5use App::Ping903::Command ':exit_codes'; 5use App::Mangemanche::Command ':exit_codes';
6 6
7sub run { 7sub 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 @@
1package App::Ping903::Command::nagios; 1package App::Mangemanche::Command::nagios;
2use strict; 2use strict;
3use warnings; 3use warnings;
4use parent 'App::Ping903::Command'; 4