Zonemaster-CLI
view release on metacpan or search on metacpan
script/zonemaster-cli view on Meta::CPAN
#!/usr/bin/env perl
use 5.14.2;
use warnings;
use Zonemaster::CLI;
use File::Spec;
use autodie;
sub read_conf_file {
# Returns list of command line parameters. List can be empty.
my ( $conf_file ) = @_;
my @lines;
open my $fh, '<', $conf_file;
while ( <$fh> ) {
chomp;
next if /^\s*$/;
next if /^\s*#/;
push @lines, $_;
}
return @lines;
}
# Load default arguments from file in home directory, if any
# This must be loaded before any global file to make the local
# file take precedence
my $home_dir = ( ( getpwuid( $< ) )[7] ) || $ENV{HOME};
my $home_conf_file = File::Spec->catfile( $home_dir, '.zonemaster', 'cli.args' );
if ( -r $home_conf_file ) {
my @lines = read_conf_file( $home_conf_file );
unshift @ARGV, @lines;
}
# Load default arguments from global file, if any
my @global_conf = ( '/etc/zonemaster/cli.args', '/usr/local/etc/zonemaster/cli.args' ); # Order is significant.
my $global_conf_file;
for my $p ( @global_conf ) {
if ( -e $p and -r $p ) {
$global_conf_file = $p;
last;
}
}
if ( defined $global_conf_file ) {
my @lines = read_conf_file( $global_conf_file );
unshift @ARGV, @lines;
}
eval {
my $exitstatus = Zonemaster::CLI->run( @ARGV );
exit $exitstatus;
};
print STDERR $@;
exit $Zonemaster::CLI::EXIT_GENERIC_ERROR;
=head1 NAME
zonemaster-cli - run Zonemaster tests from the command line
=head1 SYNOPSIS
zonemaster-cli [--help | --version | --list-tests]
zonemaster-cli [OPTIONS] --dump-profile
zonemaster-cli [OPTIONS] DOMAINNAME
=head1 DESCRIPTION
L<zonemaster-cli> is a command-line interface to the Zonemaster test engine.
It takes instructions the user provides as command line arguments, transforms
them into suitable API calls to the engine, runs the test suite and prints the
resulting messages. By default, the messages will be translated by the engine's
translation module, with the corresponding timestamp and logging level when
printed. See the available options below.
=head1 OPTIONS
=head2 Special Options
=over 4
=item B<-h>, B<--help>
Print brief usage information and exit.
( run in 3.243 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )