| 1 | # ABSTRACT: create a new repository | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package App::Pinto::Command::init; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Class::Load; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Pinto::Util qw(is_remote_repo); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use base 'App::Pinto::Command'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our $VERSION = '0.14'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my ( $self, $app ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | [ 'description=s' => 'Description of the initial stack' ], | |||||||||||||||||||||||||||||||||||||||||
| 26 | [ 'no-default' => 'Do not mark the initial stack as the default' ], | ||||||||||||||||||||||||||||||||||||||||||
| 27 | [ 'recurse!' => 'Default recursive behavior (negatable)' ], | ||||||||||||||||||||||||||||||||||||||||||
| 28 | [ 'source=s@' => 'URI of upstream repository (repeatable)' ], | ||||||||||||||||||||||||||||||||||||||||||
| 29 | [ 'stack=s' => 'Name of the initial stack' ], | ||||||||||||||||||||||||||||||||||||||||||
| 30 | [ 'target-perl-version|tpv=s' => 'Default perl version for new stacks' ], | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub validate_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_args: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ( $self, $opts, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | $self->usage_error('Only one argument is allowed') | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if @{$args} > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my ( $self, $opts, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $global_opts = $self->app->global_options; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | die "Must specify a repository root directory\n" | ||||||||||||||||||||||||||||||||||||||||||
| 53 | unless $global_opts->{root} ||= | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | ($args->[0] || $ENV{PINTO_REPOSITORY_ROOT}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$global_opts->{"root"} ||= $args->[0] || $ENV{"PINTO_REPOSITORY_ROOT"}
$args->[0] || $ENV{'PINTO_REPOSITORY_ROOT'}
MC/DC0%0/3
$global_opts->{"root"} ||= $args->[0] || $ENV{"PINTO_REPOSITORY_ROOT"}
$global_opts->{"root"}
$args->[0]
$ENV{'PINTO_REPOSITORY_ROOT'}
Truth table0%0/4
A ||= B || C
A= $global_opts->{"root"}B= $args->[0]C= $ENV{'PINTO_REPOSITORY_ROOT'}
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | die "Cannot create remote repositories\n" | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if is_remote_repo( $global_opts->{root} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | # Combine repeatable "source" options into one space-delimited "sources" option. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # TODO: Use a config file format that allows multiple values per key (MVP perhaps?). | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $opts->{sources} = join ' ', @{ delete $opts->{source} } if defined $opts->{source}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $initializer = $self->load_initializer->new; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $initializer->init( %{$global_opts}, %{$opts} ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub load_initializer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_initializer: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $class = 'Pinto::Initializer'; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ( $ok, $error ) = Class::Load::try_load_class($class); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return $class if $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $msg = $error =~ m/Can't locate .* in \@INC/ ## no critic (ExtendedFormatting) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | ? "Must install Pinto to create new repositories\n" | ||||||||||||||||||||||||||||||||||||||||||
| 79 | : $error; | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | die $msg; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||||||||||||||||