aboutsummaryrefslogtreecommitdiff
path: root/beam
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-03-09 12:59:53 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2017-03-09 12:59:53 +0200
commit05aa806b33f91172e0eba0cee4a28ccfec204d3a (patch)
treea5bb1e4046180cf6d1ec15cd8db0110224ad1513 /beam
parent980ccd3e2749ffc0370388fb0bd2977c608d90b0 (diff)
downloadbeam-05aa806b33f91172e0eba0cee4a28ccfec204d3a.tar.gz
beam-05aa806b33f91172e0eba0cee4a28ccfec204d3a.tar.bz2
Implement informational options for each subcommand
* Makefile.PL: Update. * beam (VERSION): New variavble. Analyze informational options prior to invoking the selected module's run method. * lib/App/Beam/Backup.pm: Add POD markup. * lib/App/Beam/List.pm: Likewise.
Diffstat (limited to 'beam')
-rwxr-xr-xbeam69
1 files changed, 65 insertions, 4 deletions
diff --git a/beam b/beam
index 8944668..3b55bc4 100755
--- a/beam
+++ b/beam
@@ -3,8 +3,9 @@
use strict;
use Pod::Usage;
use Pod::Man;
+use Pod::Find qw(pod_where);
use File::Basename;
-use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order);
+use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order auto_version);
use Unix::Sysexits;
use Data::Dumper;
@@ -12,8 +13,46 @@ my $progname = basename($0);
my $progdescr = 'backup manager';
my %args;
+our $VERSION = '1.6.90';
+
+=head1 NAME
+
+beam - backup manager
+
+=head1 SYNOPSIS
+
+B<beam>
+[B<-dn>]
+[B<-f> I<FILE>]
+[B<--config-file=>I<FILE>
+[B<--debug>]
+[B<--dry-run>]
+I<COMMAND> [I<ARGS>]
+
+B<beam> B<-h> | B<--help> | B<--usage> | B<--version>
+
+=cut
+
+sub pod_usage_msg {
+ my ($obj) = @_;
+ my %args;
+ open my $fd, '>', \my $msg;
+
+ $args{-input} = pod_where({-inc => 1}, ref($obj)) if defined $obj;
+ pod2usage(-verbose => 99,
+ -sections => 'NAME',
+ -output => $fd,
+ -exitval => 'NOEXIT',
+ %args);
+ my @a = split /\n/, $msg;
+ $msg = $a[1];
+ $msg =~ s/^\s+//;
+ $msg =~ s/ - /: /;
+ return $msg;
+}
+
GetOptions("h" => sub {
- pod2usage(-message => "$progname: $progdescr",
+ pod2usage(-message => pod_usage_msg(),
-exitstatus => EX_OK);
},
"help" => sub {
@@ -43,11 +82,33 @@ my %ctab = (
}
);
-unless (defined($ctab{$ARGV[0]})) {
+my $command = shift;
+
+unless (defined($ctab{$command})) {
print STDERR "$progname: no such command\n";
exit(EX_USAGE);
}
-my $beam = $ctab{$ARGV[0]}(%args);
+
+my $beam = $ctab{$command}(%args);
+
+Getopt::Long::Configure('pass_through');
+GetOptions("h" => sub {
+ pod2usage(-message => pod_usage_msg($beam),
+ -input => pod_where({-inc => 1}, ref($beam)),
+ -exitstatus => EX_OK);
+ },
+ "help" => sub {
+ pod2usage(-input => pod_where({-inc => 1}, ref($beam)),
+ -exitstatus => EX_OK,
+ -verbose => 2);
+ },
+ "usage" => sub {
+ pod2usage(-input => pod_where({-inc => 1}, ref($beam)),
+ -exitstatus => EX_OK,
+ -verbose => 0);
+ });
+Getopt::Long::Configure('no_pass_through');
+
$beam->begin;
$beam->run(@ARGV);
$beam->end;

Return to:

Send suggestions and report system problems to the System administrator.