App/lcpan/Cmd/dist_scripts.pm

filter: Statementstmt 47.0% 16 / 34 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 42.5% 20 / 47 CC 5 SCAR 29.5
CC
5
Cov
38%
handle_cmd
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 19.1
« App/lcpan/Cmd/mod2author.pm ↑ Summary App/lcpan/Cmd/dist_mods.pm »
1 package App::lcpan::Cmd::dist_scripts;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require App::lcpan;
8  
9 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10 1 our $DATE = '2023-09-26'; # DATE
11 1 our $DIST = 'App-lcpan'; # DIST
12 1 our $VERSION = '1.074'; # VERSION
13  
14 1 our %SPEC;
15  
16 1 $SPEC{'handle_cmd'} = {
17 v => 1.1,
18 summary => 'List scripts in a distribution',
19 args => {
20 %App::lcpan::common_args,
21 %App::lcpan::dists_args,
22 %App::lcpan::detail_args,
23 },
24 };
25 0 ▶sub handle_cmd {
Subroutine handle_cmd: not called CC=5 SCAR=34.0
Pod documented
26 0 my %args = @_;
27  
28 0 my $state = App::lcpan::_init(\%args, 'ro');
29 0 my $dbh = $state->{dbh};
30  
31 0 my @wheres;
32 0 push @wheres, "file.dist_name IN (".join(",", map {$dbh->quote($_)} @{ $args{dists} }).")";
33 0 my $detail = $args{detail};
34  
35 0 my $sth = $dbh->prepare("SELECT
36 script.name name,
37 file.dist_name dist,
38 script.abstract abstract
39 FROM script
40 LEFT JOIN file ON script.file_id=file.id
41 WHERE ".join(" AND ", @wheres)."
42 ORDER BY name DESC");
43 0 $sth->execute();
44 0 my @res;
45 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
46 0 ▶ delete $row->{dist} unless @{ $args{dists} } > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @{$args{"dists"};} > 1 0 0 0
47 0 ▶ push @res, $detail ? $row : $row->{name};
Branch: 1 branch
BranchTrueFalseTotal
$detail ? : 0 0 0
48 }
49 0 my $resmeta = {};
50 0 ▶ $resmeta->{'table.fields'} = [qw/name dist abstract/]
Branch: 1 branch
BranchTrueFalseTotal
if $detail 0 0 0
51 if $detail;
52 0 [200, "OK", \@res, $resmeta];
53 }
54  
55 1 1;
56 # ABSTRACT: List scripts in a distribution
57  
58 __END__
« App/lcpan/Cmd/mod2author.pm ↑ Summary App/lcpan/Cmd/dist_mods.pm »