App-Sqitch
view release on metacpan or search on metacpan
lib/App/Sqitch/Role/TargetConfigCommand.pm view on Meta::CPAN
package App::Sqitch::Role::TargetConfigCommand;
use 5.010;
use strict;
use warnings;
use utf8;
use Moo::Role;
use App::Sqitch::Types qw(HashRef);
use App::Sqitch::X qw(hurl);
use Path::Class;
use Try::Tiny;
use URI::db;
use Locale::TextDomain qw(App-Sqitch);
use List::Util qw(first);
use File::Path qw(make_path);
use namespace::autoclean;
use constant extra_target_keys => ();
our $VERSION = 'v1.6.1'; # VERSION
requires 'command';
requires 'options';
requires 'configure';
requires 'sqitch';
requires 'extra_target_keys';
requires 'default_target';
has properties => (
is => 'ro',
isa => HashRef,
default => sub { {} },
);
around options => sub {
my ($orig, $class) = @_;
return ($class->$orig), (map { "$_=s" } $class->extra_target_keys), qw(
plan-file|f=s
registry=s
client=s
extension=s
top-dir=s
dir|d=s%
set|s=s%
);
};
around configure => sub {
my ( $orig, $class, $config, $opt ) = @_;
# Grab the options we're responsible for.
my $props = {};
for my $key (
$class->extra_target_keys,
qw(plan_file registry client extension top_dir dir)
) {
$props->{$key} = delete $opt->{$key} if exists $opt->{$key};
}
# Let the command take care of its options.
my $params = $class->$orig($config, $opt);
# Convert file option to Class::Path::File object.
if ( my $file = $props->{plan_file} ) {
$props->{plan_file} = file($file)->cleanup;
}
# Convert directory option to Class::Path::Dir object.
if ( my $file = $props->{top_dir} ) {
$props->{top_dir} = dir($file)->cleanup;
}
( run in 1.983 second using v1.01-cache-2.11-cpan-39bf76dae61 )