aboutsummaryrefslogtreecommitdiff
path: root/beam
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-02-28 17:52:37 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2017-02-28 17:52:37 +0200
commitbdc4ce4b346a08c67969b848ec69996ea9c46e00 (patch)
treeed0e6bcace653c711a56731050e08d3d298e5e4a /beam
parent2f40b28caabbd90f72c3e4faf7bbd46dc4d9ec88 (diff)
downloadbeam-bdc4ce4b346a08c67969b848ec69996ea9c46e00.tar.gz
beam-bdc4ce4b346a08c67969b848ec69996ea9c46e00.tar.bz2
Improve run-time configuration framework; provide boilerplate for the backup subcommand
Diffstat (limited to 'beam')
-rwxr-xr-xbeam49
1 files changed, 49 insertions, 0 deletions
diff --git a/beam b/beam
new file mode 100755
index 0000000..48a9ebd
--- /dev/null
+++ b/beam
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+
+use strict;
+use App::Beam::Backup;
+use Pod::Usage;
+use Pod::Man;
+use File::Basename;
+use Getopt::Long qw(:config gnu_getopt no_ignore_case require_order);
+use Unix::Sysexits;
+use Data::Dumper;
+
+my $progname = basename($0);
+my $progdescr = 'backup manager';
+my %args;
+
+GetOptions("h" => sub {
+ pod2usage(-message => "$progname: $progdescr",
+ -exitstatus => EX_OK);
+ },
+ "help" => sub {
+ pod2usage(-exitstatus => EX_OK, -verbose => 2);
+ },
+ "usage" => sub {
+ pod2usage(-exitstatus => EX_OK, -verbose => 0);
+ },
+ "debug|d" => sub { $args{debug}++ },
+ "dry-run|n" => sub { $args{dry_run} = 1 },
+ "config-file|f=s" => sub { $args{config} = $_[1] }
+) or exit(EX_USAGE);
+
+unless (@ARGV) {
+ print STDERR "$progname: no command name\n";
+ exit(EX_USAGE);
+}
+
+my %ctab = (
+ backup => sub {
+ return new App::Beam::Backup(@_);
+ }
+);
+
+unless (defined($ctab{$ARGV[0]})) {
+ print STDERR "$progname: no such command\n";
+ exit(EX_USAGE);
+}
+my $beam = $ctab{$ARGV[0]}(%args);
+$beam->begin;
+$beam->run(@ARGV);
+$beam->end;

Return to:

Send suggestions and report system problems to the System administrator.