#!perl

use 5.010;
use strict;
use warnings;
use Log::Any '$log';

use App::PMUtils;
use Perinci::CmdLine::Any -prefer_lite=>1;

our $DATE = '2014-08-17'; # DATE
our $VERSION = '0.21'; # VERSION

our %SPEC;
$SPEC{pmcore} = {
    v => 1.1,
    summary => 'Check if Perl module is in core',
    description => <<'_',



_
    args => {
        module => {
            schema => 'str*',
            req    => 1,
            pos    => 0,
            completion => $App::PMUtils::_complete_module,
        },
        modver => {
            schema => 'str*',
            pos    => 1,
            # XXX complete using Module::Corelist
        },
    },
    result_naked=>1,
};
sub pmcore {
    require Module::CoreList;

    my %args = @_;
    my $mod = $args{module};
    $mod =~ s/\.pm$//; $mod =~ s!/!::!g; # convenience
    my $ver = $args{modver};

    my $ans;
    if ($ver) {
        $ans = Module::CoreList->first_release($mod, $ver);
    } else {
        $ans = Module::CoreList->first_release($mod);
    }
    my $modv = "$mod".($ver ? " version $ver" : "");

    if ($ans) {
        return "$modv was first released with perl $ans";
    } else {
        return "$modv was not in CORE (or so I think)";
    }
}

Perinci::CmdLine::Any->new(
    url => '/main/pmcore',
)->run;

# ABSTRACT: Check if Perl module is in core
# PODNAME: pmcore

__END__

=pod

=encoding UTF-8

=head1 NAME

pmcore - Check if Perl module is in core

=head1 VERSION

This document describes version 0.21 of pmcore (from Perl distribution App-PMUtils), released on 2014-08-17.

=head1 SYNOPSIS

 % pmcore MIME::Base64
 MIME::Base64 was first released with perl v5.7.3

 % pmcore Foo
 Foo was not in CORE (or so I think)

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-PMUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/sharyanto/perl-App-PMUtils>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-PMUtils>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.

=head1 AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
