diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-03-09 12:59:53 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-03-09 12:59:53 +0200 |
commit | 05aa806b33f91172e0eba0cee4a28ccfec204d3a (patch) | |
tree | a5bb1e4046180cf6d1ec15cd8db0110224ad1513 /lib | |
parent | 980ccd3e2749ffc0370388fb0bd2977c608d90b0 (diff) | |
download | beam-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 'lib')
-rw-r--r-- | lib/App/Beam/Backup.pm | 44 | ||||
-rw-r--r-- | lib/App/Beam/List.pm | 59 |
2 files changed, 98 insertions, 5 deletions
diff --git a/lib/App/Beam/Backup.pm b/lib/App/Beam/Backup.pm index 78e62f4..ed8953b 100644 --- a/lib/App/Beam/Backup.pm +++ b/lib/App/Beam/Backup.pm @@ -8,14 +8,52 @@ our @ISA = qw(App::Beam); use Unix::Sysexits; +=head1 NAME + +beam backup - create new backup + +=head1 SYNOPSIS + +B<beam> [I<OPTIONS>] B<backup> + +=head1 DESCRIPTION + +=head1 OPTIONS + +=over 4 + +=item B<-h> + +Print a short help summary. + +=item B<--help> + +Display manpage. + +=item B<--usage> + +Print a short command line usage reminder. + +=back + +=cut + sub run { my $self = shift; - shift; # Skip subcommand name - $self->abend(EX_USAGE, "bad number of arguments") if @_; + #GetOptionsFromArray(\@_, ...); + my @items = split /\s+/, $self->get('core.items'); + if (@_) { + push @items, $self->names_of('item'); + foreach my $item (@_) { + $self->abend(EX_USAGE, "$item: no such item defined") + unless grep { $item eq $_ } @items; + } + @items = @_; + } $self->lock(); - foreach my $item (split /\s+/, $self->get('core.items')) { + foreach my $item (@items) { my $backend = $self->{backend}{$self->get("item.$item.backend")}; $backend->backup($item); } diff --git a/lib/App/Beam/List.pm b/lib/App/Beam/List.pm index ac7031f..b786e3f 100644 --- a/lib/App/Beam/List.pm +++ b/lib/App/Beam/List.pm @@ -5,6 +5,8 @@ use Carp; use POSIX qw(strftime); use Unix::Sysexits; use Getopt::Long qw(GetOptionsFromArray); +use Pod::Usage; +use Pod::Man; use App::Beam qw(:result); our @ISA = qw(App::Beam); @@ -15,18 +17,71 @@ my %result_string = ( RESULT_FAILURE() => 'FAILURE' ); +=head1 NAME + +beam list - list existing backups + +=head1 SYNOPSIS + +B<beam> +[I<OPTIONS>] +B<list> +[B<-v>] +[B<--verbose>] +[I<ITEM>...] + +B<beam list> B<-h> | B<--help> | B<--usage> | B<--version> + +=head1 DESCRIPTION + +Lists existing backups. + +=head1 OPTIONS + +=over 4 + +=item B<-v>, B<--verbose> + +Verbosely lists each backup item. + +=back + +Informational options: + +=over 4 + +=item B<-h> + +Print a short help summary. + +=item B<--help> + +Display manpage. + +=item B<--usage> + +Print a short command line usage reminder. + +=back + +=cut + sub run { my $self = shift; my $verbose; - shift; - GetOptionsFromArray(\@_, "verbose|v" => \$verbose); + GetOptionsFromArray(\@_, + "verbose|v" => \$verbose); + $self->abend(EX_USAGE, "bad number of arguments") if @_; $self->lock(); my @stat = @{$self->{status}}; shift @stat; + my $i = 0; foreach my $ent (@stat) { + ++$i; + printf("%3d ", $i); print strftime "%c ", localtime $ent->{timestamp}; printf("% 3d% 3d% 3d %s", $ent->{cycle}, $ent->{round}, $ent->{level}, $result_string{$ent->{result}}); |