App-lcpan

 view release on metacpan or  search on metacpan

lib/App/lcpan/Cmd/dist_meta.pm  view on Meta::CPAN

package App::lcpan::Cmd::dist_meta;

use 5.010;
use strict;
use warnings;

require App::lcpan;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2023-09-26'; # DATE
our $DIST = 'App-lcpan'; # DIST
our $VERSION = '1.074'; # VERSION

our %SPEC;

$SPEC{'handle_cmd'} = {
    v => 1.1,
    summary => 'Get distribution metadata',
    args => {
        %App::lcpan::common_args,
        %App::lcpan::dist_args,
    },
};
sub handle_cmd {
    my %args = @_;

    my $state = App::lcpan::_init(\%args, 'ro');
    my $dbh = $state->{dbh};

    my ($cpanid, $file_name, $file_id, $has_metajson, $has_metayml) = $dbh->selectrow_array(
        "SELECT cpanid, name, id, has_metajson, has_metayml FROM file WHERE is_latest_dist AND dist_name=?", {}, $args{dist});
    $file_id or return [404, "No such dist '$args{dist}'"];
    $has_metajson || $has_metayml or return [412, "Dist does not have metadata"];

    my $path = App::lcpan::_fullpath($file_name, $state->{cpan}, $cpanid);
    my $la_res = App::lcpan::_list_archive_members($path, $file_name, $file_id);
    return [500, "Can't read archive $path: $la_res->[1]"] unless $la_res->[0] == 200;

    my $gm_res = App::lcpan::_get_meta($la_res);
    return [500, "Can't extract distmeta from $path: $gm_res->[1]"] unless $gm_res->[0] == 200;
    $gm_res;
}

1;
# ABSTRACT: Get distribution metadata

__END__

=pod

=encoding UTF-8

=head1 NAME

App::lcpan::Cmd::dist_meta - Get distribution metadata

=head1 VERSION

This document describes version 1.074 of App::lcpan::Cmd::dist_meta (from Perl distribution App-lcpan), released on 2023-09-26.

=head1 FUNCTIONS


=head2 handle_cmd

Usage:

 handle_cmd(%args) -> [$status_code, $reason, $payload, \%result_meta]

Get distribution metadata.

This function is not exported.

Arguments ('*' denotes required arguments):

=over 4

=item * B<cpan> => I<dirname>

Location of your local CPAN mirror, e.g. E<sol>pathE<sol>toE<sol>cpan.

Defaults to C<~/cpan>.

=item * B<dist>* => I<perl::distname>

(No description)

=item * B<index_name> => I<filename> (default: "index.db")

Filename of index.

If C<index_name> is a filename without any path, e.g. C<index.db> then index will



( run in 1.000 second using v1.01-cache-2.11-cpan-788537b7465 )