lib/Riji/CLI.pm

filter: Statementstmt 80.8% 38 / 47 Branchbran 37.5% 3 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 73.5% 50 / 68 CC 6 SCAR 14.9
CC
6
Cov
74%
run
8.8
__ANON__
2.0
BEGIN
1.0
CRAP 4.4
« lib/Riji.pm ↑ Summary lib/Riji/Model/Article.pm »
1 package Riji::CLI;
2 10 ▶use feature ':5.10';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use IPC::Cmd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Plack::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use String::CamelCase ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 10 ▶sub run {
Subroutine run: called CC=6 SCAR=21.8
Pod undocumented
12 10 my ($self, @args) = @_;
13  
14 10 local @ARGV = @args;
15 10 my @commands;
16 10 my $p = Getopt::Long::Parser->new(
17 config => [ "no_ignore_case", "pass_through" ],
18 );
19 $p->getoptions(
20 0 ▶ "h|help" => sub { unshift @commands, 'help' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 10 'version!' => \my $version,
22 );
23 10 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 0 10 10
24 0 require Riji;
25 0 say "Riji: $Riji::VERSION"; exit 0;
26 }
27 10 push @commands, @ARGV;
28  
29 10 ▶ my $cmd = shift @commands || 'help';
Condition50%1/2
shift @commands || 'help'
l!l
100
MC/DC0%0/1
shift @commands || 'help'
shift @commands
Truth table50%1/2
A
A= shift @commands
Aresult
11
00
30 10 ▶ if (my $cmd = IPC::Cmd::can_run("riji-$cmd")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cmd = IPC::Cmd::can_run("riji-$cmd")) 0 10 10
31 0 exec $cmd, @commands;
32 }
33  
34 10 $cmd =~ s/-/_/g;
35 10 my $class = String::CamelCase::camelize $cmd;
36  
37 10 local $@;
38 10 $class = eval { Plack::Util::load_class($class, 'Riji::CLI') };
39 10 ▶ if (my $err = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $@) 0 10 10
40 0 ▶ if ($err =~ m!Can't locate Riji/CLI!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err =~ m[Can't locate Riji/CLI]) 0 0 0
41 0 warn "sub command `$cmd` not found\n"; exit 1;
42 }
43 0 die $@;
44 }
45 10 $class->run(@commands);
46 }
47  
48 10 1;
« lib/Riji.pm ↑ Summary lib/Riji/Model/Article.pm »