| 1 | package App::lcpan::Cmd::dist_mods; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | require App::lcpan; | |||||||||
| 8 | |||||||||||
| 9 | 2 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||
| 10 | 2 | our $DATE = '2023-09-26'; # DATE | |||||||||
| 11 | 2 | our $DIST = 'App-lcpan'; # DIST | |||||||||
| 12 | 2 | our $VERSION = '1.074'; # VERSION | |||||||||
| 13 | |||||||||||
| 14 | 2 | our %SPEC; | |||||||||
| 15 | |||||||||||
| 16 | 2 | $SPEC{'handle_cmd'} = { | |||||||||
| 17 | v => 1.1, | ||||||||||
| 18 | summary => 'List modules in a distribution', | ||||||||||
| 19 | args => { | ||||||||||
| 20 | %App::lcpan::common_args, | ||||||||||
| 21 | %App::lcpan::dist_args, | ||||||||||
| 22 | %App::lcpan::detail_args, | ||||||||||
| 23 | }, | ||||||||||
| 24 | }; | ||||||||||
| 25 | 0 | ▶ | sub handle_cmd { | ||||||||
|
Subroutine
handle_cmd: not called CC=4 SCAR=30.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 $dist = $args{dist}; | |||||||||
| 32 | 0 | my $detail = $args{detail}; | |||||||||
| 33 | |||||||||||
| 34 | 0 | my $sth = $dbh->prepare("SELECT | |||||||||
| 35 | module.name name, | ||||||||||
| 36 | module.version version, | ||||||||||
| 37 | module.abstract abstract | ||||||||||
| 38 | FROM module | ||||||||||
| 39 | LEFT JOIN file ON module.file_id=file.id | ||||||||||
| 40 | WHERE file.dist_name=? | ||||||||||
| 41 | ORDER BY name DESC"); | ||||||||||
| 42 | 0 | $sth->execute($dist); | |||||||||
| 43 | 0 | my @res; | |||||||||
| 44 | 0 | ▶ | while (my $row = $sth->fetchrow_hashref) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | ▶ | push @res, $detail ? $row : $row->{name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | } | ||||||||||
| 47 | 0 | my $resmeta = {}; | |||||||||
| 48 | 0 | ▶ | $resmeta->{'table.fields'} = [qw/name version abstract/] | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | if $detail; | ||||||||||
| 50 | 0 | [200, "OK", \@res, $resmeta]; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 2 | 1; | |||||||||
| 54 | # ABSTRACT: List modules in a distribution | ||||||||||
| 55 | |||||||||||
| 56 | __END__ | ||||||||||