aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2017-03-13 08:31:02 +0200
committerSergey Poznyakoff <gray@gnu.org>2017-03-13 08:31:02 +0200
commit1c146d2aab40a87b241592eb894e0177a188eec9 (patch)
tree84b396c7d42fb6805c77d7e96444da6fdaf673c9
parenta80525354251593ba4b6830a5da32b0b04b1d518 (diff)
downloadbeam-1c146d2aab40a87b241592eb894e0177a188eec9.tar.gz
beam-1c146d2aab40a87b241592eb894e0177a188eec9.tar.bz2
Implement the 'lint' subcommand.
-rwxr-xr-xbeam4
-rw-r--r--lib/App/Beam.pm15
-rw-r--r--lib/App/Beam/Lint.pm58
3 files changed, 76 insertions, 1 deletions
diff --git a/beam b/beam
index 3154e71..080087c 100755
--- a/beam
+++ b/beam
@@ -83,6 +83,10 @@ my %ctab = (
list => sub {
use App::Beam::List;
return new App::Beam::List(@_);
+ },
+ lint => sub {
+ use App::Beam::Lint;
+ return new App::Beam::Lint(@_);
}
);
diff --git a/lib/App/Beam.pm b/lib/App/Beam.pm
index 1eeb625..d4b9242 100644
--- a/lib/App/Beam.pm
+++ b/lib/App/Beam.pm
@@ -15,6 +15,18 @@ use App::Beam::History::Entry qw(:state);
my $default_config_file = '/etc/beam.conf';
+sub ck_dir {
+ my ($v) = @_;
+
+ if (-d $$v) {
+ return undef;
+ } elsif (! -e $$v) {
+ return "directory does not exist";
+ } else {
+ return "not a directory";
+ }
+}
+
sub ck_bool {
my ($vref) = @_;
my %bool = ( '1' => 1,
@@ -94,7 +106,8 @@ my %parameters = (
section => {
statfile => { default => '/var/spool/beam/beam.state' },
tempdir => { default => '/tmp' },
- archivedir => { default => '/var/backups' },
+ archivedir => { default => '/var/backups',
+ check => \&ck_dir },
items => 1
}
},
diff --git a/lib/App/Beam/Lint.pm b/lib/App/Beam/Lint.pm
new file mode 100644
index 0000000..0f57717
--- /dev/null
+++ b/lib/App/Beam/Lint.pm
@@ -0,0 +1,58 @@
+package App::Beam::Lint;
+
+use strict;
+use Carp;
+
+require App::Beam;
+our @ISA = qw(App::Beam);
+
+use Unix::Sysexits;
+
+=head1 NAME
+
+beam lint - check configuration file syntax
+
+=head1 SYNOPSIS
+
+B<beam> [I<OPTIONS>] B<lint>
+
+=head1 DESCRIPTION
+
+Checks the B<beam>(1) configuration file. Any errors found are reported
+on standard error.
+
+Exit code is 0 if no errors were found and 78 otherwise.
+
+=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 begin {
+ my $self = shift;
+ exit(EX_CONFIG) unless $self->parse();
+ $self->load_backends;
+}
+
+sub end {
+ exit(0);
+}
+
+sub run {
+ my $self = shift;
+}

Return to:

Send suggestions and report system problems to the System administrator.