Catmandu/Cmd/run.pm

filter: Statementstmt 83.3% 30 / 36 Branchbran 40.0% 4 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 73.3% 44 / 60 CC 7 SCAR 19.0
CC
7
Cov
71%
command
11.5
BEGIN
1.0
BEGIN
1.0
CRAP 6.7
« Catmandu/Cmd/convert.pm ↑ Summary Catmandu/CQLSearchable.pm »
1 package Catmandu::Cmd::run;
2  
3 14 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 14 our $VERSION = '1.2025';
6  
7 14 ▶use parent 'Catmandu::Cmd';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use Catmandu;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use Catmandu::Util qw(require_package);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶sub command_opt_spec {
Subroutine command_opt_spec: called CC=1 SCAR=0.0
Pod documented
13 (
14 1 ["var=s%", ""],
15 ["fix=s@", ""],
16 ["preprocess|pp", ""],
17 ["verbose|v", ""],
18 ["i", "interactive mode"],
19 );
20 }
21  
22 1 ▶sub command {
Subroutine command: called CC=7 SCAR=24.4
Pod documented
23 1 my ($self, $opts, $args) = @_;
24  
25 1 ▶ if (defined $opts->{i} || !defined $args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts->{'i'} or not defined $args->[0]) { } 0 1 1
Condition33%1/3
defined $opts->{"i"} or not defined $args->[0]
l!l&&r!l&&!r
001
MC/DC0%0/2
defined $opts->{"i"} or not defined $args->[0]
defined $opts->{"i"} not defined $args->[0]
Truth table33%1/3
A or not(B)
A= defined $opts->{"i"}B= not defined $args->[0]
ABresult
1X1
011
000
26 0 my $pkg = require_package('Catmandu::Interactive');
27 0 my $app = Catmandu::Interactive->new();
28 0 $app->run();
29 }
30 else {
31 1 my $fix_file = $args->[0];
32 1 ▶ $fix_file = [\*STDIN] unless defined $fix_file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fix_file 0 1 1
33  
34 1 $opts->{fix} = [$fix_file];
35  
36 1 my $from = Catmandu->importer('Null');
37 1 $from = $self->_build_fixer($opts)->fix($from);
38  
39 1 ▶ if ($opts->verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->verbose) 0 1 1
40 0 $from = $from->benchmark;
41 }
42  
43 1 my $into = Catmandu->exporter('Null');
44 1 my $n = $into->add_many($from);
45 1 $into->commit;
46  
47 1 ▶ if ($opts->verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->verbose) 0 1 1
48 0 ▶ say STDERR $n == 1 ? "converted 1 item" : "converted $n items";
Branch: 1 branch
BranchTrueFalseTotal
$n == 1 ? : 0 0 0
49 0 say STDERR "done";
50 }
51 }
52 }
53  
54 14 1;
55  
56 __END__
« Catmandu/Cmd/convert.pm ↑ Summary Catmandu/CQLSearchable.pm »