Minilla/CLI.pm

filter: Statementstmt 59.1% 58 / 98 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 70.3% 19 / 27 Podpod 0.0% 0 / 1 totaltotal 50.0% 77 / 154 CC 13 SCAR 25.0
CC
13
Cov
47%
_run
42.0
run
30.0
__ANON__
12.0
CRAP 12.2
« Minilla/CLI/Test.pm ↑ Summary Minilla/CLI/Clean.pm »
1 package Minilla::CLI;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Minilla;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Minilla::Errors;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Minilla::Project;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Minilla::Util qw(find_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Minilla::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Minilla::CLI::New;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Minilla::CLI::Help;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Minilla::CLI::Dist;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Minilla::CLI::Test;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Minilla::CLI::Release;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Minilla::CLI::Install;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 0 ▶sub run {
Subroutine run: not called CC=5 SCAR=34.0
Pod undocumented
27 0 my ($self, @args) = @_;
28  
29 0 ▶ STDOUT->flush or die "Cannot flush standard output: $!";
Branch: 1 branch
BranchTrueFalseTotal
"STDOUT"->flush or die "Cannot flush standard output: $!" 0 0 0
30 0 ▶ open my $stdout, '>&', \*STDOUT
Branch: 1 branch
BranchTrueFalseTotal
open my $stdout, ">&", \*STDOUT or die "Cannot save standard output: $!" 0 0 0
31 or die "Cannot save standard output: $!";
32 0 ▶ local $Minilla::Logger::SLOG_OUTPUT = $Minilla::Logger::SLOG_OUTPUT || $stdout;
Condition0%0/3
$Minilla::Logger::SLOG_OUTPUT || $stdout
l!l&&r!l&&!r
000
MC/DC0%0/2
$Minilla::Logger::SLOG_OUTPUT || $stdout
$Minilla::Logger::SLOG_OUTPUT $stdout
Truth table0%0/3
A || B
A= $Minilla::Logger::SLOG_OUTPUTB= $stdout
ABresult
1X1
011
000
33 0 ▶ open STDOUT, '>&', \*STDERR
Branch: 1 branch
BranchTrueFalseTotal
open STDOUT, ">&", \*STDERR or die "Cannot redirect standard output to standard error: $!" 0 0 0
34 or die "Cannot redirect standard output to standard error: $!";
35  
36 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 0 $self->_run(@args);
38 0 ▶ } catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 die $_;
40 0 ▶ } finally {
Subroutine __ANON__: not called CC=3 SCAR=24.8
41 0 my $flushed = STDOUT->flush;
42 0 my $flush_error = $!;
43 0 ▶ open STDOUT, '>&', $stdout
Branch: 1 branch
BranchTrueFalseTotal
open STDOUT, ">&", $stdout or die "Cannot restore standard output: $!" 0 0 0
44 or die "Cannot restore standard output: $!";
45 0 ▶ die "Cannot flush redirected standard output: $flush_error" unless $flushed;
Branch: 1 branch
BranchTrueFalseTotal
unless $flushed 0 0 0
46 0 };
47 }
48  
49 0 ▶sub _run {
Subroutine _run: not called CC=6 SCAR=37.4
50 0 my ($self, @args) = @_;
51  
52 0 local $Minilla::AUTO_INSTALL = 1;
53 0 ▶ local $Minilla::Logger::COLOR = -t STDERR ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-t STDERR ? : 0 0 0
54 0 local @ARGV = @args;
55 0 my @commands;
56 my $version;
57 0 my $p = Getopt::Long::Parser->new(
58 config => [ "no_ignore_case", "pass_through" ],
59 );
60 $p->getoptions(
61 0 ▶ "h|help" => sub { unshift @commands, 'help' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 "color!" => \$Minilla::Logger::COLOR,
63 "debug!" => \$Minilla::DEBUG,
64 "auto-install!" => \$Minilla::AUTO_INSTALL,
65 'version!' => \$version,
66 );
67  
68 0 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 0 0 0
69 0 print "Minilla: $Minilla::VERSION\n";
70 0 exit 0;
71 }
72  
73 0 push @commands, @ARGV;
74  
75 0 ▶ my $cmd = shift @commands || 'help';
Condition0%0/2
shift @commands || 'help'
l!l
00
MC/DC0%0/1
shift @commands || 'help'
shift @commands
Truth table0%0/2
A
A= shift @commands
Aresult
11
00
76 0 my $klass = sprintf("Minilla::CLI::%s", ucfirst($cmd));
77  
78 ## no critic
79 0 ▶ if (eval sprintf("require %s; 1;", $klass)) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval sprintf('require %s; 1;', $klass)) { } 0 0 0
80 0 my $exit_code = 0;
81 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
82 0 $klass->run(@commands);
83 0 ▶ } catch {
Subroutine __ANON__: not called CC=2 SCAR=17.9
84 0 ▶ if (/Minilla::Error::CommandExit/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/Minilla::Error::CommandExit/) 0 0 0
85 0 $exit_code = 1;
86 0 return;
87 }
88 0 errorf("%s\n", $_);
89 0 exit 1;
90 0 };
91 0 return $exit_code;
92 } else {
93 0 warnf("Could not find command '%s'\n", $cmd);
94 0 ▶ if ($@ !~ /^Can't locate Minilla/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@ =~ /^Can't locate Minilla/) 0 0 0
95 0 errorf("$@\n");
96 }
97 0 exit 2;
98 }
99 }
100  
101 1 1;
« Minilla/CLI/Test.pm ↑ Summary Minilla/CLI/Clean.pm »