| 1 | # ABSTRACT: Command-line driver for Pinto | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package App::Pinto; | ||||||||||||||||||||||||||||||||||||||||||||||
| 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 App::Cmd::Setup -app; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Pinto::Util qw(is_remote_repo); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '0.14'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub global_opt_spec { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
global_opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | [ 'root|r=s' => 'Path to your repository root directory' ], | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | [ 'color|colour!' => 'Colorize any output (negatable)' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | [ 'password|p=s' => 'Password for server authentication' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | [ 'quiet|q' => 'Only report fatal errors' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | [ 'username|u=s' => 'Username for server authentication' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | [ 'verbose|v+' => 'More diagnostic output (repeatable)' ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub pinto { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pinto: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return $self->{pinto} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"pinto"} ||= do {
my $global_options = $self->global_options;
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root");
delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"});
$global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"};
$global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-";
my $pinto_class = $self->pinto_class_for($global_options->{"root"});
Class::Load::load_class($pinto_class);
$pinto_class->new(%{$global_options;})
}
MC/DC0%0/2
$self->{"pinto"} ||= do {
my $global_options = $self->global_options;
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root");
delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"});
$global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"};
$global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-";
my $pinto_class = $self->pinto_class_for($global_options->{"root"});
Class::Load::load_class($pinto_class);
$pinto_class->new(%{$global_options;})
}
$self->{"pinto"}
do {
my $global_options = $self->global_options;
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root");
delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"});
$global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"};
$global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-";
my $pinto_class = $self->pinto_class_for($global_options->{"root"});
Class::Load::load_class($pinto_class);
$pinto_class->new(%{$global_options;})
}
Truth table0%0/3
A ||= B
A= $self->{"pinto"}B= do {
my $global_options = $self->global_options;
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root");
delete @{$global_options;}{"username", "password"} unless is_remote_repo($global_options->{"root"});
$global_options->{"color"} = 0 if $ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"};
$global_options->{"password"} = $self->_prompt_for_password if defined $global_options->{"password"} and $global_options->{"password"} eq "-";
my $pinto_class = $self->pinto_class_for($global_options->{"root"});
Class::Load::load_class($pinto_class);
$pinto_class->new(%{$global_options;})
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $global_options = $self->global_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $global_options->{root} ||= $ENV{PINTO_REPOSITORY_ROOT} | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | || $self->usage_error('Must specify a repository root'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root")
$ENV{'PINTO_REPOSITORY_ROOT'} || $self->usage_error('Must specify a repository root')
MC/DC0%0/3
$global_options->{"root"} ||= $ENV{"PINTO_REPOSITORY_ROOT"} || $self->usage_error("Must specify a repository root")
$global_options->{"root"}
$ENV{'PINTO_REPOSITORY_ROOT'}
$self->usage_error('Must specify a repository root')
Truth table0%0/4
A ||= B || C
A= $global_options->{"root"}B= $ENV{'PINTO_REPOSITORY_ROOT'}C= $self->usage_error('Must specify a repository root')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # Discard password and username arguments if this is not a | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # remote repository. StrictConstrutor will not allow them. | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | delete @{$global_options}{qw(username password)} | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if not is_remote_repo($global_options->{root}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # Disable color if STDOUT is not a tty, unless it has already been | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # explicitly enabled. For example: pinto --color ls | less -R | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $global_options->{color} = 0 if ($ENV{PINTO_NO_COLOR} or not -t STDOUT) | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | and not defined $global_options->{color}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}
$ENV{"PINTO_NO_COLOR"} or not -t STDOUT
MC/DC0%0/3
$ENV{"PINTO_NO_COLOR"} || !-t(STDOUT) and not defined $global_options->{"color"}
$ENV{"PINTO_NO_COLOR"}
not -t STDOUT
not defined $global_options->{"color"}
Truth table0%0/5
A or not(B) and not(C)
A= $ENV{"PINTO_NO_COLOR"}B= not -t STDOUTC= not defined $global_options->{"color"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $global_options->{password} = $self->_prompt_for_password | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if defined $global_options->{password} and $global_options->{password} eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $global_options->{"password"} and $global_options->{"password"} eq "-"
MC/DC0%0/2
defined $global_options->{"password"} and $global_options->{"password"} eq "-"
defined $global_options->{"password"}
$global_options->{"password"} eq "-"
Truth table0%0/3
A and B
A= defined $global_options->{"password"}B= $global_options->{"password"} eq "-"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $pinto_class = $self->pinto_class_for( $global_options->{root} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | Class::Load::load_class($pinto_class); | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $pinto_class->new( %{$global_options} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub pinto_class_for { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pinto_class_for: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my ( $self, $root ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | return is_remote_repo($root) ? 'Pinto::Remote' : 'Pinto'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub _prompt_for_password { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prompt_for_password: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | require Encode; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | require IO::Prompt; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $repo = $self->global_options->{root}; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $prompt = "Password for repository at $repo: "; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $input = IO::Prompt::prompt( $prompt, -echo => '*', -tty ); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $password = Encode::decode_utf8($input); | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return $password; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||