App-cpm
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/cpm/CLI.pm view on Meta::CPAN
use App::cpm::Requirement;
use App::cpm::Resolver::Cascade;
use App::cpm::Resolver::MetaCPAN;
use App::cpm::Resolver::MetaDB;
use App::cpm::Util qw(WIN32 determine_home maybe_abs);
use App::cpm::Worker;
use App::cpm::version;
use App::cpm;
use CPAN::Meta;
use Command::Runner;
use Config;
use Cwd ();
use File::Copy ();
use File::Path ();
use File::Spec;
use Getopt::Long qw(:config no_auto_abbrev no_ignore_case bundling);
use List::Util ();
use Module::CPANfile;
use Module::cpmfile;
use Parallel::Pipes::App;
use Pod::Text ();
use local::lib ();
sub new {
my ($class, %option) = @_;
my $prebuilt = exists $ENV{PERL_CPM_PREBUILT} && !$ENV{PERL_CPM_PREBUILT} ? 0 : 1;
bless {
argv => undef,
home => determine_home,
cwd => Cwd::cwd(),
workers => WIN32 ? 1 : 5,
snapshot => "cpanfile.snapshot",
dependency_file => undef,
local_lib => "local",
cpanmetadb => "https://cpanmetadb.plackperl.org/v1.0/",
_default_mirror => 'https://cpan.metacpan.org/',
retry => 1,
configure_timeout => 60,
build_timeout => 3600,
test_timeout => 1800,
with_requires => 1,
with_recommends => 0,
with_suggests => 0,
with_configure => 0,
with_build => 1,
with_test => 1,
with_runtime => 1,
with_develop => 0,
feature => [],
notest => 1,
prebuilt => $] >= 5.012 && $prebuilt,
pureperl_only => 0,
static_install => 1,
default_resolvers => 1,
%option
}, $class;
}
sub parse_options {
my $self = shift;
local @ARGV = @_;
my ($mirror, @resolver, @feature);
my $with_option = sub {
my $n = shift;
("with-$n", \$self->{"with_$n"}, "without-$n", sub { $self->{"with_$n"} = 0 });
};
my @type = qw(requires recommends suggests);
my @phase = qw(configure build test runtime develop);
GetOptions
"L|local-lib-contained=s" => \($self->{local_lib}),
"color!" => \($self->{color}),
"g|global" => \($self->{global}),
"mirror=s" => \$mirror,
"v|verbose" => \($self->{verbose}),
"w|workers=i" => \($self->{workers}),
"target-perl=s" => \my $target_perl,
"test!" => sub { $self->{notest} = $_[1] ? 0 : 1 },
"cpanfile=s" => sub { $self->{dependency_file} = { type => "cpanfile", path => $_[1] } },
"cpmfile=s" => sub { $self->{dependency_file} = { type => "cpmfile", path => $_[1] } },
"metafile=s" => sub { $self->{dependency_file} = { type => "metafile", path => $_[1] } },
"snapshot=s" => \($self->{snapshot}),
"sudo" => \($self->{sudo}),
"r|resolver=s@" => \@resolver,
"default-resolvers!" => \($self->{default_resolvers}),
"mirror-only" => \($self->{mirror_only}),
"dev" => \($self->{dev}),
"man-pages" => \($self->{man_pages}),
"home=s" => \($self->{home}),
"retry!" => \($self->{retry}),
"exclude-vendor!" => \($self->{exclude_vendor}),
"configure-timeout=i" => \($self->{configure_timeout}),
"build-timeout=i" => \($self->{build_timeout}),
"test-timeout=i" => \($self->{test_timeout}),
"show-progress!" => \($self->{show_progress}),
"prebuilt!" => \($self->{prebuilt}),
"reinstall" => \($self->{reinstall}),
"pp|pureperl|pureperl-only" => \($self->{pureperl_only}),
"static-install!" => \($self->{static_install}),
"with-all" => sub { map { $self->{"with_$_"} = 1 } @type, @phase },
(map $with_option->($_), @type),
(map $with_option->($_), @phase),
"feature=s@" => \@feature,
"show-build-log-on-failure" => \($self->{show_build_log_on_failure}),
or return 0;
$self->{local_lib} = maybe_abs($self->{local_lib}, $self->{cwd}) unless $self->{global};
$self->{home} = maybe_abs($self->{home}, $self->{cwd});
$self->{resolver} = \@resolver;
$self->{feature} = \@feature if @feature;
$self->{mirror} = $self->normalize_mirror($mirror) if $mirror;
$self->{color} = 1 if !defined $self->{color} && -t STDOUT;
$self->{show_progress} = 1 if !WIN32 && !defined $self->{show_progress} && -t STDOUT;
if ($target_perl) {
die "--target-perl option conflicts with --global option\n" if $self->{global};
die "--target-perl option can be used only if perl version >= 5.18.0\n" if $] < 5.018;
# 5.8 is interpreted as 5.800, fix it
$target_perl = "v$target_perl" if $target_perl =~ /^5\.[1-9]\d*$/;
$target_perl = sprintf '%0.6f', App::cpm::version->parse($target_perl)->numify;
$target_perl = '5.008' if $target_perl eq '5.008000';
$self->{target_perl} = $target_perl;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 2.726 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )