App-lcpan-CmdBundle-cpantesters

 view release on metacpan or  search on metacpan

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

package App::lcpan::Cmd::cpantesters_author;

use 5.010001;
use strict;
use warnings;
use Log::ger;

use Perinci::Object;

require App::lcpan;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-03-27'; # DATE
our $DIST = 'App-lcpan-CmdBundle-cpantesters'; # DIST
our $VERSION = '0.003'; # VERSION

our %SPEC;

$SPEC{handle_cmd} = {
    v => 1.1,
    summary => 'Open author page on CPAN Testers matrix',
    description => <<'_',

Given author with CPAN ID `CPANID`, this will open
`http://matrix.cpantesters.org/?author=CPANID`. `CPANID` will first be checked for
existence in local index database.

_
    args => {
        %App::lcpan::common_args,
        %App::lcpan::authors_args,
    },
};
sub handle_cmd {
    my %args = @_;

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

    my $envres = envresmulti();
    for my $author (@{ $args{authors} }) {
        my ($cpanid) = $dbh->selectrow_array(
            "SELECT cpanid FROM author WHERE cpanid=?", {}, uc $author);
        defined $cpanid or do {
            $envres->add_result(404, "No such author '$author'");
            next;
        };

        require Browser::Open;
        my $url = "http://matrix.cpantesters.org/?author=$cpanid";
        my $err = Browser::Open::open_browser($url);
        if ($err) {
            $envres->add_result(500, "Can't open browser for URL $url");
        } else {
            $envres->add_result(200, "OK");
        }
    }
    $envres->as_struct;
}

1;
# ABSTRACT: Open author page on CPAN Testers matrix

__END__

=pod

=encoding UTF-8

=head1 NAME

App::lcpan::Cmd::cpantesters_author - Open author page on CPAN Testers matrix

=head1 VERSION

This document describes version 0.003 of App::lcpan::Cmd::cpantesters_author (from Perl distribution App-lcpan-CmdBundle-cpantesters), released on 2022-03-27.

=head1 DESCRIPTION

This module handles the L<lcpan> subcommand C<cpantesters-author>.

=head1 FUNCTIONS


=head2 handle_cmd

Usage:

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

Open author page on CPAN Testers matrix.

Given author with CPAN ID C<CPANID>, this will open
CL<http://matrix.cpantesters.org/?author=CPANID>. C<CPANID> will first be checked for
existence in local index database.

This function is not exported.

Arguments ('*' denotes required arguments):

=over 4

=item * B<authors>* => I<array[str]>

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



( run in 1.761 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )