aboutsummaryrefslogtreecommitdiff
path: root/beam
blob: 48a9ebd1473029c2c160ea6acb915a98639634f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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.