App-PMUtils

 view release on metacpan or  search on metacpan

script/pmminversion  view on Meta::CPAN

        module => $App::PMUtils::arg_module_multiple,
        detector => {
            schema => ['str*', in=>[qw/Perl::MinimumVersion Perl::MinimumVersion::Fast/]],
            default => 'Perl::MinimumVersion',
        },
        #with_minimum_external_version => {
        #    schema => 'bool',
        #},
        with_minimum_syntax_version => {
            schema => 'bool',
        },
        with_minimum_explicit_version => {
            schema => 'bool',
        },
    },
};
sub pmminversion {
    require Module::Path::More;

    my %args = @_;
    my $mods = $args{module};
    my $det  = $args{detector} // 'Perl::MinimumVersion';

    my $found;
    my $res = [];
    for my $mod (@$mods) {
        $mod =~ s!/!::!g;
        my $mpath = Module::Path::More::module_path(module=>$mod);
        unless ($mpath) {
            warn "Module $mod is not installed";
            next;
        }
        $found++;

        my $pmv;
        if ($det eq 'Perl::MinimumVersion::Fast') {
            require Perl::MinimumVersion::Fast;
            $pmv = Perl::MinimumVersion::Fast->new($mpath);
        } else {
            require Perl::MinimumVersion;
            $pmv = Perl::MinimumVersion->new($mpath);
        }

        my $v;
        my $rec = {
            module => $mod,
        };
        $v = $pmv->minimum_version;
        $rec->{minimum_version} = "$v";
        if ($args{with_minimum_explicit_version}) {
            $rec->{minimum_explicit_version} = $pmv->minimum_explicit_version;
        }
        if ($args{with_minimum_syntax_version}) {
            $rec->{minimum_syntax_version} = $pmv->minimum_syntax_version;
        }

        push @$res, $rec;
    }

    if (!$found) {
        [404, "No such module(s): " . join(", ", @$mods)];
    } else {
        [200, "OK", $res, {
            'table.fields' => [qw/module minimum_version minimum_explicit_version minimum_syntax_version/],
        }];
    }
}

Perinci::CmdLine::Any->new(
    url => '/main/pmminversion',
    read_config => 0,
    read_env => 0,
)->run;

# ABSTRACT: Get minimum required Perl version for specified modules
# PODNAME: pmminversion

__END__

=pod

=encoding UTF-8

=head1 NAME

pmminversion - Get minimum required Perl version for specified modules

=head1 VERSION

This document describes version 0.745 of pmminversion (from Perl distribution App-PMUtils), released on 2024-08-30.

=head1 SYNOPSIS

 % pmminversion Some::Module Another::Module

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--detector>=I<s>

Default value:

 "Perl::MinimumVersion"

Valid values:

 ["Perl::MinimumVersion","Perl::MinimumVersion::Fast"]

=item B<--module-json>=I<s>

See C<--module>.

Can also be specified as the 1st command-line argument and onwards.

=item B<--module>=I<s@>



( run in 1.018 second using v1.01-cache-2.11-cpan-39bf76dae61 )