| 1 | package Dist::Zilla::Chrome::Term 6.040; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: chrome used for terminal-based interaction | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Dist::Zilla::Pragmas; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Digest::MD5 qw(md5); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Dist::Zilla::Types qw(OneZero); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Log::Dispatchouli 1.102220; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | #pod =head1 OVERVIEW | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | #pod This class provides a L<Dist::Zilla::Chrome> implementation for use in a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #pod terminal environment. It's the default chrome used by L<Dist::Zilla::App>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub _str_color { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_str_color: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my ($str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | state %color_for; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # I know, I know, this is ludicrous, but guess what? It's my Sunday and I | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # can spend it how I want. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | state $max = ($ENV{COLORTERM}//'') eq 'truecolor' ? 255 : 5; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$ENV{"COLORTERM"} // ""
MC/DC0%0/1
$ENV{"COLORTERM"} // ""
$ENV{"COLORTERM"}
Truth table0%0/2
A
A= $ENV{"COLORTERM"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | state $min = $max == 255 ? 384 : 5; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | state $inc = $max == 255 ? 16 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | state $fmt = $max == 255 ? 'r%ug%ub%u' : 'rgb%u%u%u'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | return $color_for{$str} //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$color_for{$str} //= do {
my(@rgb) = map({$_ % $max;} unpack("CCC", md5($str)));
my $i = ($rgb[0] + $rgb[1] + $rgb[2]) % 3;
while (1) {
last if $rgb[0] + $rgb[1] + $rgb[2] >= $min;
my $next = $i++ % 3;
$rgb[$next] = abs $max - $rgb[$next];
};
sprintf $fmt, @rgb
}
MC/DC0%0/2
$color_for{$str} //= do {
my(@rgb) = map({$_ % $max;} unpack("CCC", md5($str)));
my $i = ($rgb[0] + $rgb[1] + $rgb[2]) % 3;
while (1) {
last if $rgb[0] + $rgb[1] + $rgb[2] >= $min;
my $next = $i++ % 3;
$rgb[$next] = abs $max - $rgb[$next];
};
sprintf $fmt, @rgb
}
$color_for{$str}
do {
my(@rgb) = map({$_ % $max;} unpack("CCC", md5($str)));
my $i = ($rgb[0] + $rgb[1] + $rgb[2]) % 3;
while (1) {
last if $rgb[0] + $rgb[1] + $rgb[2] >= $min;
my $next = $i++ % 3;
$rgb[$next] = abs $max - $rgb[$next];
};
sprintf $fmt, @rgb
}
Truth table0%0/3
A //= B
A= $color_for{$str}B= do {
my(@rgb) = map({$_ % $max;} unpack("CCC", md5($str)));
my $i = ($rgb[0] + $rgb[1] + $rgb[2]) % 3;
while (1) {
last if $rgb[0] + $rgb[1] + $rgb[2] >= $min;
my $next = $i++ % 3;
$rgb[$next] = abs $max - $rgb[$next];
};
sprintf $fmt, @rgb
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my @rgb = map { $_ % $max } unpack 'CCC', md5($str); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $i = ($rgb[0] + $rgb[1] + $rgb[2]) % 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | last if $rgb[0] + $rgb[1] + $rgb[2] >= $min; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $next = $i++ % 3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $rgb[$next] = abs($max - $rgb[$next]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | sprintf $fmt, @rgb; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | has logger => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | isa => 'Log::Dispatchouli', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | writer => '_set_logger', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | builder => '_build_logger', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 20 | ▶ | sub _build_logger { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_logger: called CC=6 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 20 | my $enc = $self->term_enc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 20 | ▶ | if ($enc && Encode::resolve_alias($enc)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$enc and &Encode::resolve_alias($enc)
MC/DC0%0/2
$enc and &Encode::resolve_alias($enc)
$enc
&Encode::resolve_alias($enc)
Truth table33%1/3
A and B
A= $encB= &Encode::resolve_alias($enc)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 20 | my $layer = sprintf(":encoding(%s)", $enc); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 20 | binmode( STDOUT, $layer ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 20 | binmode( STDERR, $layer ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | my $logger = Log::Dispatchouli->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ident => 'Dist::Zilla', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | to_stdout => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | log_pid => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 20 | ▶ | to_self => ($ENV{DZIL_TESTING} ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | quiet_fatal => 'stdout', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 20 | ▶ | my $use_color = $ENV{DZIL_COLOR} // -t *STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{"DZIL_COLOR"} // -t *STDOUT
MC/DC0%0/2
$ENV{"DZIL_COLOR"} // -t *STDOUT
$ENV{"DZIL_COLOR"}
-t *STDOUT
Truth table33%1/3
A // B
A= $ENV{"DZIL_COLOR"}B= -t *STDOUT
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 20 | ▶ | if ($use_color) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $stdout = $logger->{dispatcher}->output('stdout'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $stdout->add_callback(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | require Term::ANSIColor; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $message = {@_}->{message}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | return $message unless $message =~ s/\A\[([^\]]+)] //; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $prefix = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return sprintf "[%s] %s", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | Term::ANSIColor::colored([ _str_color($prefix) ], $prefix), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $message; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 20 | return $logger; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | has term_ui => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | isa => 'Object', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | require Term::ReadLine; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | require Term::UI; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | Term::ReadLine->new('dzil') | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | has term_enc => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 20 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 20 | require Term::Encoding; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 20 | return Term::Encoding::get_encoding(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub prompt_str { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prompt_str: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my ($self, $prompt, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $arg ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg ||= {}
MC/DC0%0/1
$arg ||= {}
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $default = $arg->{default}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $check = $arg->{check}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | require Encode; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $term_enc = $self->term_enc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | my $encode = $term_enc | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | ? sub { Encode::encode($term_enc, shift, Encode::FB_CROAK()) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | : sub { shift }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | my $decode = $term_enc | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | ? sub { Encode::decode($term_enc, shift, Encode::FB_CROAK()) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | : sub { shift }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ($arg->{noecho}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | require Term::ReadKey; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | Term::ReadKey::ReadMode('noecho'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | my $input_bytes = $self->term_ui->get_reply( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | prompt => $encode->($prompt), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | allow => $check || sub { length $_[0] }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | (defined $default | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$check || sub {
length $_[0];
}
MC/DC0%0/2
$check || sub {
length $_[0];
}
$check
sub {
length $_[0];
}
Truth table0%0/3
A || B
A= $checkB= sub {
length $_[0];
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ? (default => $encode->($default)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ($arg->{noecho}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | Term::ReadKey::ReadMode('normal'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # The \n ending user input disappears under noecho; this ensures | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # the next output ends up on the next line. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | my $input = $decode->($input_bytes) // q{}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&$decode($input_bytes) // ""
MC/DC0%0/1
&$decode($input_bytes) // ""
&$decode($input_bytes)
Truth table0%0/2
A
A= &$decode($input_bytes)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | chomp $input; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return $input; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub prompt_yn { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prompt_yn: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ($self, $prompt, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | $arg ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg ||= {}
MC/DC0%0/1
$arg ||= {}
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $default = $arg->{default}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (! $self->_isa_tty) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if (defined $default) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return OneZero->coerce($default); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | $self->logger->log_fatal( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | "want interactive input, but terminal doesn't appear interactive" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | my $input = $self->term_ui->ask_yn( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | prompt => $prompt, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | (defined $default ? (default => OneZero->coerce($default)) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return $input; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub _isa_tty { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isa_tty: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $isa_tty = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
-t STDOUT or not -f STDOUT || -c STDOUT
-f STDOUT || -c STDOUT
MC/DC0%0/4
-t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT))
-t STDIN
-t STDOUT
-f STDOUT
-c STDOUT
Truth table0%0/5
A && B or not(C || D)
A= -t STDINB= -t STDOUTC= -f STDOUTD= -c STDOUT
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return $isa_tty; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | sub prompt_any_key { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prompt_any_key: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my ($self, $prompt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $prompt ||= 'press any key to continue'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prompt ||= "press any key to continue"
MC/DC0%0/1
$prompt ||= "press any key to continue"
$prompt
Truth table0%0/2
A
A= $prompt
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $isa_tty = $self->_isa_tty; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ($isa_tty) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | local $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | print $prompt; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | require Term::ReadKey; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | Term::ReadKey::ReadMode('cbreak'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | Term::ReadKey::ReadKey(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | Term::ReadKey::ReadMode('normal'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | with 'Dist::Zilla::Role::Chrome'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||