diff options
-rw-r--r-- | lib/App/BorgRestore.pm | 26 | ||||
-rwxr-xr-x | script/borg-restore.pl | 6 |
2 files changed, 26 insertions, 6 deletions
diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index 6e92c1c..746dffc 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -5,11 +5,7 @@ use warnings; our $VERSION = "2.0.0"; - - -1; -__END__ - +=pod =encoding utf-8 =head1 NAME @@ -49,3 +45,23 @@ Florian Pritz E<lt>bluewind@xinu.atE<gt> =cut +sub new { + my $class = shift; + my $opts = shift; + + my $self = {}; + bless $self, $class; + + $self->{opts} = $opts; + + return $self; +} + +sub debug { + my $self = shift; + say STDERR @_ if $self->{opts}->{debug}; +} + + +1; +__END__ diff --git a/script/borg-restore.pl b/script/borg-restore.pl index f586ed5..7ec23e1 100755 --- a/script/borg-restore.pl +++ b/script/borg-restore.pl @@ -155,6 +155,7 @@ See gpl-3.0.txt for the full license text. use v5.10; +use App::BorgRestore; use App::BorgRestore::Borg; use App::BorgRestore::DB; use App::BorgRestore::Helper; @@ -176,9 +177,10 @@ use Time::HiRes; my %opts; my %db; +my $app; sub debug { - say STDERR @_ if $opts{debug}; + $app->debug(@_); } sub find_archives { @@ -541,6 +543,8 @@ sub main { GetOptions(\%opts, "help|h", "debug", "update-cache|u", "destination|d=s", "time|t=s") or pod2usage(2); pod2usage(0) if $opts{help}; + $app = App::BorgRestore->new(\%opts); + if ($opts{"update-cache"}) { update_cache(); return 0; |