diff options
-rwxr-xr-x | beam | 4 | ||||
-rw-r--r-- | lib/App/Beam.pm | 15 | ||||
-rw-r--r-- | lib/App/Beam/Lint.pm | 58 |
3 files changed, 76 insertions, 1 deletions
@@ -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; +} |