| 1 | #!perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package App::plx; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.902004'; # 0.902.4 | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Cwd (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use lib (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use File::Which (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use List::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use local::lib (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | our %orig_env = %ENV; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | { local $0 = $0 eq '-' ? 'plx' : $0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | local::lib->import('--deactivate-all') } | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | delete @ENV{grep /^PERL/, keys %ENV} | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | no lib @Config{qw(sitearch sitelibexp)}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | my $fs = 'File::Spec'; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | my $self = do { | |||||||||||||||||||||||||||||||||||||||||
| 31 | package Perl::Layout::Executor::_self; | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 301 | ▶ | sub self { package DB; () = caller(2); $DB::args[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
self: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use overload '%{}' => sub { self }, fallback => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 114 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 114 | my ($meth) = (our $AUTOLOAD =~ /([^:]+)$/); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 114 | self->$meth(@_[1..$#_]); | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | bless([], __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub barf { die "$_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
barf: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub stderr { warn "$_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stderr: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub say { print "$_[0]\n" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 33 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=20.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 33 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | bless @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 178 | ▶ | sub layout_base_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_base_dir: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 178 | ▶ | $self->{layout_base_dir} //= $self->_build_layout_base_dir | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"layout_base_dir"} //= $self->_build_layout_base_dir
MC/DC0%0/2
$self->{"layout_base_dir"} //= $self->_build_layout_base_dir
$self->{"layout_base_dir"}
$self->_build_layout_base_dir
Truth table66%2/3
A //= B
A= $self->{"layout_base_dir"}B= $self->_build_layout_base_dir
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | ▶ | sub layout_perl { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_perl: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | ▶ | $self->{layout_perl} //= $self->_build_layout_perl | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"layout_perl"} //= $self->_build_layout_perl
MC/DC0%0/2
$self->{"layout_perl"} //= $self->_build_layout_perl
$self->{"layout_perl"}
$self->_build_layout_perl
Truth table66%2/3
A //= B
A= $self->{"layout_perl"}B= $self->_build_layout_perl
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 28 | ▶ | sub _build_layout_base_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_layout_base_dir: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 28 | my @parts = $fs->splitdir(Cwd::realpath(Cwd::getcwd())); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 28 | my $cand; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 28 | my $reason = ''; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 28 | ▶ | while (@parts > 1) { # go back to one step before root at most | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 84 | $cand = $fs->catdir(@parts); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 84 | ▶ | return $cand if -d $fs->catdir($cand, '.plx'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 64 | ▶ | if (-d $fs->catdir($cand, '.git')) { # don't escape current repository | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $reason = ' due to .git directory'; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 64 | pop @parts; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | barf "Couldn't find .plx directory (stopped searching at ${cand}${reason})"; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 6 | ▶ | sub _build_layout_perl { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_layout_perl: called CC=5 SCAR=24.7
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 6 | my $perl_bin = $self->read_config_entry('perl'); | |||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | ▶ | unless ($perl_bin) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $perl_spec = $self->read_config_entry('perl.spec'); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | barf "No perl and no perl.spec in config" unless $perl_spec; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $self->run_config_perl_set($perl_spec); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $perl_bin = $self->read_config_entry('perl'); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | barf "Rehydration of perl from perl.spec failed" unless $perl_bin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 6 | ▶ | barf "perl binary ${perl_bin} not executable" unless -x $perl_bin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 6 | return $perl_bin; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | sub layout_libspec_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_libspec_config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | [ grep $_->[1], | |||||||||||||||||||||||||||||||||||||||||
| 91 | map [ $_, $self->read_config_entry([ libspec => $_ ]) ], | ||||||||||||||||||||||||||||||||||||||||||
| 92 | $self->list_config_names('libspec') ]; | ||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | ▶ | sub layout_lib_specs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_lib_specs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | my $base_dir = $self->layout_base_dir; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | local *_ = sub { Cwd::realpath($fs->rel2abs(shift, $base_dir)) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | [ map [ ($_->[0] =~ /\.([^.]+)$/), _($_->[1]) ], | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | @{$self->layout_libspec_config} ]; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 99 | ▶ | sub layout_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 99 | my ($self, @path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 99 | $fs->catfile($self->layout_base_dir, @path); | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 71 | ▶ | sub layout_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 71 | my ($self, @path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 71 | $fs->catdir($self->layout_base_dir, @path); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 17 | ▶ | sub ensure_layout_config_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_layout_config_dir: called CC=4 SCAR=14.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 17 | ▶ | barf ".plx directory does not exist" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | unless -d $self->layout_dir('.plx'); | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 10 | my $format = $self->read_config_entry('format'); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 10 | ▶ | barf ".plx directory has no format specifier" unless $format; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 10 | ▶ | barf ".plx format ${format} unknown" unless $format eq '1'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 96 | ▶ | sub layout_config_file { shift->layout_file('.plx', @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_config_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 51 | ▶ | sub layout_config_dir { shift->layout_dir('.plx', @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout_config_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 68 | ▶ | sub write_config_entry { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_config_entry: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 68 | my ($self, $path, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 68 | ▶ | my $file = $self->layout_config_file(ref($path) ? @$path : $path); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 68 | ▶ | open my $wfh, '>', $file or die "Couldn't open ${file}: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 68 | print $wfh "${value}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub clear_config_entry { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_config_entry: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $file = $self->layout_config_file(ref($path) ? @$path : $path); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | unlink($file) or barf "Failed to unlink ${file}: $!" if -e $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
-e $file && (unlink($file) || barf("Failed to unlink ${file}: $!"))
unlink $file or barf("Failed to unlink ${file}: $!")
MC/DC0%0/3
-e $file && (unlink($file) || barf("Failed to unlink ${file}: $!"))
-e $file
unlink $file
barf("Failed to unlink ${file}: $!")
Truth table0%0/4
A && B or C
A= -e $fileB= unlink $fileC= barf("Failed to unlink ${file}: $!")
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 28 | ▶ | sub read_config_entry { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_config_entry: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 28 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 28 | ▶ | my $file = $self->layout_config_file(ref($path) ? @$path : $path); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 28 | ▶ | return undef unless -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 28 | ▶ | open my $rfh, '<', $file or die "Couldn't open ${file}: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 28 | chomp(my $value = <$rfh>); | |||||||||||||||||||||||||||||||||||||||||
| 142 | 28 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 7 | ▶ | sub list_config_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_config_names: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 7 | ▶ | my $dir = $self->layout_config_dir(ref($path) ? @$path : $path); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 7 | ▶ | return () unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | ▶ | opendir my($dh), $dir or die "Couldn't opendir ${dir}: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | return grep -f $fs->catfile($dir, $_), sort readdir($dh); | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | ▶ | sub slurp_command { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slurp_command: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | my ($self, @cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 3 | ▶ | open my $slurp_fh, '-|', @cmd | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | or barf "Failed to start command (".join(' ', @cmd)."): $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | chomp(my @slurp = <$slurp_fh>); | |||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | return @slurp; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub prepend_env { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepend_env: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ($self, $env, @parts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $ENV{$env} = join(':', @parts, $ENV{$env}||()); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{$env} || ()
MC/DC0%0/2
$ENV{$env} || ()
$ENV{$env}
()
Truth table0%0/3
A || B
A= $ENV{$env}B= ()
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub setup_env_for_ll { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_env_for_ll: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | local $0 = $0 eq '-' ? 'plx' : $0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | local::lib->import($path); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub setup_env_for_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_env_for_dir: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $self->prepend_env(PERL5LIB => $path); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | ▶ | sub setup_env { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_env: called CC=6 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | $ENV{PERL_PLX_BASE} = $self->layout_base_dir; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | my ($site_libs) = $self->slurp_command( | |||||||||||||||||||||||||||||||||||||||||
| 180 | $self->layout_perl, '-MConfig', '-e', | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 'print join(",", @Config{qw(sitearch sitelibexp)})' | ||||||||||||||||||||||||||||||||||||||||||
| 182 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | $ENV{PERL5OPT} = '-M-lib='.$site_libs; | |||||||||||||||||||||||||||||||||||||||||
| 184 | $ENV{$_} = $self->read_config_entry([ env => $_ ]) | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | for $self->list_config_names('env'); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | my $perl_dirname = File::Basename::dirname($self->layout_perl); | |||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | our %orig_env; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | ▶ | unless (grep $_ eq $perl_dirname, split ':', $orig_env{PATH}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self->prepend_env(PATH => $perl_dirname); | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 3 | foreach my $lib_spec (@{$self->layout_lib_specs}) { | |||||||||||||||||||||||||||||||||||||||||
| 192 | 9 | my ($type, $path) = @$lib_spec; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 9 | ▶ | next unless $path and -d $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$path and -d $path
MC/DC0%0/2
$path and -d $path
$path
-d $path
Truth table33%1/3
A and B
A= $pathB= -d $path
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->${\"setup_env_for_${type}"}($path); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | sub cmd_search_path { qw(.plx/cmd dev bin) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_search_path: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | sub run_action_commands { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_commands: called CC=17 SCAR=47.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | my ($self, $filter) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | my @commands; | |||||||||||||||||||||||||||||||||||||||||
| 205 | my %seen; | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | foreach my $dirname ($self->cmd_search_path) { | |||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | ▶ | next unless -d (my $dir = $self->layout_dir($dirname)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | opendir my ($dh), $dir or barf "Couldn't open ${dir}: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | foreach my $entry (sort readdir($dh)) { | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | next if $entry =~ /^\.+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $file = $self->layout_file($dirname, $entry); | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | next unless -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | unless ($seen{$entry}++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | push @commands, [ $entry, "${dirname}/${entry}" ]; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | my $path = do { local $ENV{PATH} = ''; $self->setup_env; $ENV{PATH} }; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | foreach my $dir (split ':', $path) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | opendir my ($dh), $dir; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | foreach my $entry (sort readdir($dh)) { | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | next if $entry =~ /^\.+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $file = $fs->catfile($dir, $entry); | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | next unless -x $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | push @commands, [ $entry, $file ] unless $seen{$entry}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | if ($filter) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my $match = $filter =~ m{^/(.+)/$} ? $1 : qr/^\Q${filter}/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | @commands = grep { $_->[0] =~ $match } @commands; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | my $max = List::Util::max(map length($_->[0]), @commands); | |||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | my $base = $self->layout_base_dir; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | my $home = $ENV{HOME}; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | foreach my $command (@commands) { | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my ($name, $path) = @$command; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $path =~ s/^\Q${base}\///; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $path =~ s/^\Q${home}/~/ if $home; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | say sprintf("%-${max}s %s", $name, $path); | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 11 | ▶ | sub run_action_bareinit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_bareinit: called CC=6 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 11 | my ($self, $perl) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 11 | ▶ | my $dir = $fs->catdir($self->{layout_base_dir}||Cwd::getcwd(), '.plx'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'layout_base_dir'} || Cwd::getcwd()
MC/DC0%0/2
$self->{'layout_base_dir'} || Cwd::getcwd()
$self->{'layout_base_dir'}
Cwd::getcwd()
Truth table33%1/3
A || B
A= $self->{'layout_base_dir'}B= Cwd::getcwd()
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 11 | ▶ | if (-d $dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ($perl) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | stderr <<END; | |||||||||||||||||||||||||||||||||||||||||
| 249 | .plx already initialised - if you wanted to set the perl to ${perl} run: | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | plx --config perl set ${perl} | ||||||||||||||||||||||||||||||||||||||||||
| 252 | END | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 11 | ▶ | mkdir($dir) or barf "Couldn't create ${dir}: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 11 | ▶ | $self->run_config_perl_set($perl||'perl'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$perl || 'perl'
MC/DC0%0/1
$perl || 'perl'
$perl
Truth table50%1/2
A
A= $perl
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 11 | $self->write_config_entry(format => 1); | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub run_action_userinit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_userinit: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my @perl = ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@args and not ref $args[0] and $args[0] ne "["
@args and not ref $args[0]
MC/DC0%0/3
@args and not ref $args[0] and $args[0] ne "["
@args
not ref $args[0]
$args[0] ne "["
Truth table0%0/4
A and not(B) and C
A= @argsB= not ref $args[0]C= $args[0] ne "["
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | (@args and !ref($args[0]) and $args[0] ne '[') | ||||||||||||||||||||||||||||||||||||||||||
| 265 | ? shift(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 266 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 267 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | barf "--userinit requires \$HOME to be set" unless $ENV{HOME}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | $self->run_action_base( | ||||||||||||||||||||||||||||||||||||||||||
| 270 | $ENV{HOME}, | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | '--multi' => | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | [ '--bareinit', @perl ], | ||||||||||||||||||||||||||||||||||||||||||
| 273 | [ qw(--config libspec add 25.perl5.ll perl5) ], | ||||||||||||||||||||||||||||||||||||||||||
| 274 | (@args ? [ '--multi', @args ] : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 275 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub run_action_userstrap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_userstrap: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | my @perl = ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@args and not ref $args[0] and $args[0] ne "["
@args and not ref $args[0]
MC/DC0%0/3
@args and not ref $args[0] and $args[0] ne "["
@args
not ref $args[0]
$args[0] ne "["
Truth table0%0/4
A and not(B) and C
A= @argsB= not ref $args[0]C= $args[0] ne "["
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | (@args and !ref($args[0]) and $args[0] ne '[') | ||||||||||||||||||||||||||||||||||||||||||
| 282 | ? shift(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 283 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->run_action_userinit( | |||||||||||||||||||||||||||||||||||||||||
| 286 | @perl, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | [ '--installself' ], | ||||||||||||||||||||||||||||||||||||||||||
| 288 | [ '--installenv' ], | ||||||||||||||||||||||||||||||||||||||||||
| 289 | @args | ||||||||||||||||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub run_action_installself { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_installself: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $last_ll; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | foreach my $lib_spec (@{$self->layout_lib_specs}) { | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my ($type, $path) = @$lib_spec; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $last_ll = $path if $type eq 'll'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | barf "No local::lib in libspec config" unless $last_ll; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->run_action_cpanm( | |||||||||||||||||||||||||||||||||||||||||
| 301 | "-l${last_ll}", '-n', | ||||||||||||||||||||||||||||||||||||||||||
| 302 | qw(App::cpanminus App::plx) | ||||||||||||||||||||||||||||||||||||||||||
| 303 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | sub run_action_installenv { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_installenv: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 308 | barf "--installenv action currently assumes bash" | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | unless $ENV{SHELL} =~ /bash/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | barf "Couldn't find .bashrc" | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | unless -f (my $bashrc = $fs->catfile($ENV{HOME}, ".bashrc")); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | my $plx_bin = do { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | local %ENV = our %orig_env; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | File::Which::which('plx-packed'); | |||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
do {
local(%ENV) = our(%orig_env);
File::Which::which('plx-packed')
} || do {
local(%ENV) = %ENV;
$self->setup_env;
File::Which::which('plx-packed')
}
MC/DC0%0/2
do {
local(%ENV) = our(%orig_env);
File::Which::which('plx-packed')
} || do {
local(%ENV) = %ENV;
$self->setup_env;
File::Which::which('plx-packed')
}
do {
local(%ENV) = our(%orig_env);
File::Which::which('plx-packed')
}
do {
local(%ENV) = %ENV;
$self->setup_env;
File::Which::which('plx-packed')
}
Truth table0%0/3
A || B
A= do {
local(%ENV) = our(%orig_env);
File::Which::which('plx-packed')
}B= do {
local(%ENV) = %ENV;
$self->setup_env;
File::Which::which('plx-packed')
}
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | local %ENV = %ENV; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $self->setup_env; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | File::Which::which('plx-packed'); | |||||||||||||||||||||||||||||||||||||||||
| 319 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | barf "Couldn't find plx in PATH" unless $plx_bin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | { | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | open my $fh, '<', $bashrc or die "Couldn't open ${bashrc} to read: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if (my ($line) = grep /plx-packed/, <$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | chomp($line); | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | stderr("Found line in .bashrc: $line"); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $base = $self->layout_base_dir; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | stderr("Appending to .bashrc"); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | open my $fh, '>>', $bashrc or die "Couldn't open ${bashrc} to append: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | print $fh "\neval \$(${plx_bin} --base ${base} --env)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 11 | ▶ | sub run_action_init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_init: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 11 | my ($self, $perl) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 11 | $self->run_action_bareinit($perl); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 11 | my $libspec_dir = $self->layout_config_dir('libspec'); | |||||||||||||||||||||||||||||||||||||||||
| 339 | 11 | ▶ | mkdir($libspec_dir) or barf "Couldn't create ${libspec_dir}: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 11 | $self->run_config_libspec_add(@$_) for ( | |||||||||||||||||||||||||||||||||||||||||
| 341 | [ '25-local.ll' => 'local' ], | ||||||||||||||||||||||||||||||||||||||||||
| 342 | [ '50-devel.ll' => 'devel' ], | ||||||||||||||||||||||||||||||||||||||||||
| 343 | [ '75-lib.dir' => 'lib' ], | ||||||||||||||||||||||||||||||||||||||||||
| 344 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 3 | ▶ | sub _which { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_which: called CC=13 SCAR=35.3
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 3 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 2 | my @env; | |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 2 | ▶ | push @env, shift @args while $args[0] =~ /^\w+=/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | my $cmd = shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | ▶ | barf "--cmd <cmd> <args>" unless $cmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 2 | ▶ | if ($fs->file_name_is_absolute($cmd)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return (exec => @env => $cmd => @args); | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | ▶ | if ($cmd eq 'perl') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | return (perl => @env => @args); | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | ▶ | if ($cmd =~ m{/}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | return (perl => @env => $cmd, @args); | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | ▶ | if ($cmd =~ /^-/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my @optargs = ($cmd, @args); | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | foreach my $optarg (@optargs) { | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | next if $optarg =~ /^-/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | foreach my $dirname ($self->cmd_search_path) { | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if (-f (my $file = $self->layout_file($dirname => $optarg))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $optarg = $file; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return (perl => @env => @optargs); | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | foreach my $dirname ($self->cmd_search_path) { | |||||||||||||||||||||||||||||||||||||||||
| 387 | 3 | ▶ | if (-f (my $file = $self->layout_file($dirname => $cmd))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return (perl => @env => $file, @args); | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | return (exec => @env => $cmd, @args); | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub run_action_which { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_which: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my ($action, @call) = $self->_which(@args); | |||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | say join(' ', 'plx', "--${action}", @call); | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | ▶ | sub run_action_cmd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_cmd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | my ($action, @call) = $self->_which(@args); | |||||||||||||||||||||||||||||||||||||||||
| 404 | 2 | $self->${\"run_action_${action}"}(@call); | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 4 | ▶ | sub run_action_perl { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_perl: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 4 | my ($self, @call) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 4 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | return $self->show_config_perl unless @call; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | my @env; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | ▶ | push @env, shift @call while $call[0] =~ /^\w+=/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | $self->run_action_exec(@env, $self->layout_perl, @call); | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | sub run_action_exec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_exec: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my ($self, @exec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $self->setup_env; | |||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | shift @exec and $ENV{$1} = $2 while $exec[0] =~ /^(\w+)=(.*)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | exec(@exec) or barf "exec of (".join(' ', @exec).") failed: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | sub find_cpanm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_cpanm: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | local %ENV = our %orig_env; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | barf "Couldn't find cpanm in \$PATH" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | unless my $cpanm = File::Which::which('cpanm'); | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $cpanm; | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | ▶ | sub run_action_cpanm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_cpanm: called CC=3 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my @cpanm = $self->find_cpanm; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | unless (@args and $args[0] =~ /^-[lL]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@args and $args[0] =~ /^-[lL]/
MC/DC0%0/2
@args and $args[0] =~ /^-[lL]/
@args
$args[0] =~ /^-[lL]/
Truth table0%0/3
A and B
A= @argsB= $args[0] =~ /^-[lL]/
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | barf "--cpanm args must start with -l or -L to specify target local::lib"; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $self->setup_env; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | system($self->layout_perl, @cpanm, @args); | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 3 | ▶ | sub run_action_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_config: called CC=7 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | my ($self, $config, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 3 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | ▶ | unless ($config) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | say "# perl"; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $self->show_config_perl; | |||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | say "# libspec"; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->show_config_libspec; | |||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if ($self->list_config_names('env')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | say "# env"; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | $self->show_config_env; | |||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | ▶ | barf "Unknown config key ${config}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | unless my $show = $self->can("show_config_${config}"); | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | ▶ | return $self->$show unless @args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 1 | ▶ | if (my $code = $self->can("run_config_${config}")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | return $self->$code(@args); | |||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | 1 | my ($subcmd, @rest) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 1 | ▶ | barf "Invalid subcommand ${subcmd} for config key ${config}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | unless my $code = $self->can("run_config_${config}_${subcmd}"); | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 | return $self->$code(@rest); | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 2 | ▶ | sub show_config_perl { say $self->layout_perl } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_config_perl: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | sub resolve_perl_via_perlbrew { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_perl_via_perlbrew: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my ($self, $perl) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | stderr "Resolving perl '${perl}' via perlbrew"; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | local %ENV = our %orig_env; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | barf "Couldn't find perlbrew in \$PATH" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | unless my $perlbrew = File::Which::which('perlbrew'); | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my @list = $self->slurp_command($perlbrew, 'list'); | |||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | barf join( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | "\n", "No such perlbrew perl '${perl}', choose from:\n", @list, '' | ||||||||||||||||||||||||||||||||||||||||||
| 481 | ) unless grep $_ eq $perl, map /(\S+)/, @list; | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my ($perl_path) = $self->slurp_command( | |||||||||||||||||||||||||||||||||||||||||
| 483 | $perlbrew, qw(exec --with), $perl, qw(perl -e), 'print $^X' | ||||||||||||||||||||||||||||||||||||||||||
| 484 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return $perl_path; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 12 | ▶ | sub run_config_perl_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_config_perl_set: called CC=6 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | 12 | my ($self, $new_perl) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 490 | 12 | ▶ | barf "plx --config perl set <perl>" unless $new_perl; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 12 | my $perl_spec = $new_perl; | |||||||||||||||||||||||||||||||||||||||||
| 492 | 12 | ▶ | unless ($new_perl =~ m{/}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 11 | ▶ | $new_perl = "perl${new_perl}" if $new_perl =~ /^5/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 11 | $new_perl =~ s/perl-5/perl5/; # perlbrew name to perl binary | |||||||||||||||||||||||||||||||||||||||||
| 495 | 11 | require File::Which; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 11 | stderr "Resolving perl '${new_perl}' via PATH"; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 11 | ▶ | if (my $resolved = File::Which::which($new_perl)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 11 | $new_perl = $resolved; | |||||||||||||||||||||||||||||||||||||||||
| 499 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $new_perl =~ s/^perl5/perl-5/; # perl binary to perlbrew name | |||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $new_perl = $self->resolve_perl_via_perlbrew($new_perl); | |||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 12 | ▶ | barf "Not executable: $new_perl" unless -x $new_perl; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 12 | $self->write_config_entry('perl.spec' => $perl_spec); | |||||||||||||||||||||||||||||||||||||||||
| 506 | 12 | $self->write_config_entry(perl => $new_perl); | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | ▶ | sub show_config_libspec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_config_libspec: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | my @ent = @{$self->layout_libspec_config}; | |||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | my $max = List::Util::max(map length($_->[0]), @ent); | |||||||||||||||||||||||||||||||||||||||||
| 512 | 1 | say sprintf("%-${max}s %s", @$_) for @ent; | |||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 33 | ▶ | sub run_named_config_add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_named_config_add: called CC=5 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 33 | my ($self, $type, $name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 517 | 33 | ▶ | barf "plx --config ${type} add <name> <value>" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$name and defined $value
MC/DC0%0/2
$name and defined $value
$name
defined $value
Truth table33%1/3
A and B
A= $nameB= defined $value
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | unless $name and defined($value); | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 33 | ▶ | unless (-d (my $dir = $self->layout_config_dir($type))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | mkdir($dir) or die "Couldn't make config dir ${dir}: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 33 | $self->write_config_entry([ $type => $name ], $value); | |||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | sub run_named_config_del { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_named_config_del: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my ($self, $type, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | barf "plx --config ${type} dev <name>" unless $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $self->clear_config_entry([ $type => $name ]); | |||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 33 | ▶ | sub run_config_libspec_add { shift->run_named_config_add(libspec => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_config_libspec_add: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | sub run_config_libspec_del { shift->run_named_config_del(libspec => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_config_libspec_del: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | sub show_config_env { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_config_env: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $max = List::Util::max( | |||||||||||||||||||||||||||||||||||||||||
| 536 | map length, my @names = $self->list_config_names('env') | ||||||||||||||||||||||||||||||||||||||||||
| 537 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 538 | say sprintf("%-${max}s %s", $_, $self->read_config_entry([ env => $_ ])) | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | for @names; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | sub run_config_env_add { shift->run_named_config_add(env => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_config_env_add: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | sub run_config_env_del { shift->run_named_config_del(env => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_config_env_del: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 4 | ▶ | sub show_env { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_env: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 4 | my ($self, $env) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 547 | 4 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | local $ENV{$env} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | $self->setup_env; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | say $_ for split ':', $ENV{$env}; | |||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | 2 | ▶ | sub run_action_libs { $self->show_env('PERL5LIB') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_libs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 2 | ▶ | sub run_action_paths { $self->show_env('PATH') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_paths: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | sub run_action_env { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_env: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $self->setup_env; | |||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my @env_change; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | our %orig_env; | |||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | foreach my $key (sort(keys %{{ %orig_env, %ENV }})) { | |||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my ($oval, $eval) = ($orig_env{$key}, $ENV{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | if (!defined($eval) or ($oval//'') ne $eval) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
not defined $eval or ($oval // "") ne $eval
$oval // ""
MC/DC0%0/2
not defined $eval or ($oval // "") ne $eval
not defined $eval
$oval
Truth table0%0/3
not(A) or B
A= not defined $evalB= $oval
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | push @env_change, [ $key, $eval ]; | |||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $shelltype = local::lib->guess_shelltype; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $shellbuild = "build_${shelltype}_env_declaration"; | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | foreach my $change (@env_change) { | |||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | print +local::lib->$shellbuild(@$change); | |||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 1 | ▶ | sub run_action_help { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_help: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | require Pod::Usage; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | Pod::Usage::pod2usage(); | |||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 1 | ▶ | sub run_action_version { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | say sprintf "%f", $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | ▶ | sub run_action_base { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_base: called CC=3 SCAR=16.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | my ($self, $base, @chain) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 586 | 1 | ▶ | unless ($base) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | 1 | say $self->layout_base_dir; | |||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | barf "--base <base> <action> <args>" unless @chain; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $self->new({ layout_base_dir => $base })->run(@chain); | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | sub _parse_multi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_multi: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my @multi; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | MULTI: while (@args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | barf "Expected multi arg [, got: $args[0]" unless $args[0] eq '['; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my @action; | |||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | while (my $el = shift @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | push @multi, \@action and next MULTI if $el eq ']'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$el eq ']' && (push(@multi, \@action) && (next MULTI))
push @multi, \@action and next MULTI
MC/DC0%0/2
$el eq ']' && (push(@multi, \@action) && (next MULTI))
$el eq ']'
push @multi, \@action
Truth table0%0/3
A && B
A= $el eq ']'B= push @multi, \@action
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | push @action, $el; | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | barf "Missing closing ] for multi"; | |||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | return @multi; | |||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | sub run_action_multi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_multi: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | return $self->run_multi(@args) if @args and ref($args[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@args and ref $args[0]
MC/DC0%0/2
@args and ref $args[0]
@args
ref $args[0]
Truth table0%0/3
A and B
A= @argsB= ref $args[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my @multi = $self->_parse_multi(@args); | |||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $self->run_multi(@multi); | |||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | sub run_multi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_multi: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my ($self, @multi) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | foreach my $multi (@multi) { | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | my @debug_multi = map +(ref($_) ? ('[', @$_, ']') : $_), @$multi; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | stderr '# '.join(' ', plx => @debug_multi); | |||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | $self->run(@$multi); | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | sub run_action_showmulti { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_action_showmulti: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my @multi = $self->_parse_multi(@args); | |||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | say join(' ', plx => @$_) for @multi; | |||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 33 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=6 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 33 | my ($self, $cmd, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 33 | ▶ | $cmd ||= '--help'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cmd ||= "--help"
MC/DC0%0/1
$cmd ||= "--help"
$cmd
Truth table50%1/2
A
A= $cmd
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | 33 | ▶ | if ($cmd eq '[') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | return $self->run_action_multi($cmd, @args); | |||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 33 | ▶ | if ($cmd =~ s/^--//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 33 | ▶ | if ($cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | 33 | my $method = join('_', 'run_action', split '-', $cmd); | |||||||||||||||||||||||||||||||||||||||||
| 641 | 33 | ▶ | if (my $code = $self->can($method)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 642 | 32 | return $self->$code(@args); | |||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 644 | 1 | barf "No such action --${cmd}, see 'perldoc plx' for the full list"; | |||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $cmd = shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $self->ensure_layout_config_dir; | |||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | return $self->run_action_cmd($cmd, @args); | |||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 1 | ▶ | caller() ? 1 : __PACKAGE__->new->run(@ARGV); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | App::plx - Perl Layout Executor | ||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | plx --help # This output | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | plx --init <perl> # Initialize layout config | ||||||||||||||||||||||||||||||||||||||||||
| 663 | plx --perl # Show layout perl binary | ||||||||||||||||||||||||||||||||||||||||||
| 664 | plx --libs # Show layout $PERL5LIB entries | ||||||||||||||||||||||||||||||||||||||||||
| 665 | plx --paths # Show layout additional $PATH entries | ||||||||||||||||||||||||||||||||||||||||||
| 666 | plx --env # Show layout env var changes | ||||||||||||||||||||||||||||||||||||||||||
| 667 | plx --cpanm -llocal --installdeps . # Run cpanm from outside $PATH | ||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | plx perl <args> # Run perl within layout | ||||||||||||||||||||||||||||||||||||||||||
| 670 | plx -E '...' # (ditto) | ||||||||||||||||||||||||||||||||||||||||||
| 671 | plx script-in-dev <args> # Run dev/ script within layout | ||||||||||||||||||||||||||||||||||||||||||
| 672 | plx script-in-bin <args> # Run bin/ script within layout | ||||||||||||||||||||||||||||||||||||||||||
| 673 | plx ./script <args> # Run script within layout | ||||||||||||||||||||||||||||||||||||||||||
| 674 | plx script/in/cwd <args> # (ditto) | ||||||||||||||||||||||||||||||||||||||||||
| 675 | plx program <args> # Run program from layout $PATH | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | =head1 WHY PLX | ||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | While perl has many tools for configuring per-project development | ||||||||||||||||||||||||||||||||||||||||||
| 680 | environments, using them can still be a little on the lumpy side. With | ||||||||||||||||||||||||||||||||||||||||||
| 681 | L<Carton>, you find yourself running one of | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | perl -Ilocal/lib/perl -Ilib bin/myapp | ||||||||||||||||||||||||||||||||||||||||||
| 684 | carton exec perl -Ilib bin/myapp | ||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | With L<App::perlbrew>, | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | perlbrew switch perl-5.28.0@libname | ||||||||||||||||||||||||||||||||||||||||||
| 689 | perl -Ilib bin/myapp | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | With L<https://github.com/tokuhirom/plenv>, | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | plenv exec perl -Ilib bin/myapp | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | and if you have more than one distinct layer of dependencies, while | ||||||||||||||||||||||||||||||||||||||||||
| 696 | L<local::lib> will happily handle that, integrating it with everything else | ||||||||||||||||||||||||||||||||||||||||||
| 697 | becomes a pain in the buttocks. | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | As a result of this, your not-so-humble author found himself regularly having | ||||||||||||||||||||||||||||||||||||||||||
| 700 | a miniature perl executor script at the root of git clones that looked | ||||||||||||||||||||||||||||||||||||||||||
| 701 | something like: | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | #!/bin/sh | ||||||||||||||||||||||||||||||||||||||||||
| 704 | eval $(perl -Mlocal::lib=--deactivate-all) | ||||||||||||||||||||||||||||||||||||||||||
| 705 | export PERL5LIB=$PWD/local/lib/perl5 | ||||||||||||||||||||||||||||||||||||||||||
| 706 | bin=$1 | ||||||||||||||||||||||||||||||||||||||||||
| 707 | shift | ||||||||||||||||||||||||||||||||||||||||||
| 708 | ~/perl5/perlbrew/perls/perl-5.28.0/bin/$bin "$@" | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | and then running: | ||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | ./pl perl -Ilib bin/myapp | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | However, much like back in 2007 frustration with explaining to other | ||||||||||||||||||||||||||||||||||||||||||
| 715 | developers how to set up L<CPAN> to install into C<~/perl5> and how to | ||||||||||||||||||||||||||||||||||||||||||
| 716 | set up one's environment variables to then find the modules so installed | ||||||||||||||||||||||||||||||||||||||||||
| 717 | led to the exercise in rage driven development that first created | ||||||||||||||||||||||||||||||||||||||||||
| 718 | L<local::lib>, walking newbies through the creation and subsequent use of | ||||||||||||||||||||||||||||||||||||||||||
| 719 | such a script was not the most enjoyable experience for anybody involved. | ||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | Thus, the creation of this module to reduce the setup process to: | ||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | cpanm App::plx | ||||||||||||||||||||||||||||||||||||||||||
| 724 | cd MyProject | ||||||||||||||||||||||||||||||||||||||||||
| 725 | plx --init 5.28.0 | ||||||||||||||||||||||||||||||||||||||||||
| 726 | plx --cpanm -llocal --notest --installdeps . | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | Follwed by being able to immediately (and even more concisely) run: | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | plx myapp | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | which will execute C<perl -Ilib bin/myapp> with the correct C<perl> and the | ||||||||||||||||||||||||||||||||||||||||||
| 733 | relevant L<local::lib> already in scope. | ||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | If this seems of use to you, the L</QUICKSTART> is next and the L</ACTIONS> | ||||||||||||||||||||||||||||||||||||||||||
| 736 | section of this document lists the full capabilities of plx. Onwards! | ||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | =head1 QUICKSTART | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | Let's assume we're going to be working on Foo-Bar, so we start with: | ||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | git clone git@github.com:arthur-nonymous/Foo-Bar.git | ||||||||||||||||||||||||||||||||||||||||||
| 743 | cd Foo-Bar | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | Assuming the perl we'd get from running just C<perl> suffices, then we | ||||||||||||||||||||||||||||||||||||||||||
| 746 | next run: | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | plx --init | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | If we want a different perl - say, we have a C<perl5.30.1> in our path, or | ||||||||||||||||||||||||||||||||||||||||||
| 751 | a C<perl-5.30.1> built in perlbrew, we'd instead run: | ||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | plx --init 5.30.1 | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | To quickly get our dependencies available, we then run: | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | plx --cpanm -llocal --notest --installdeps . | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | If the project is designed to use L<Carton> and has a C<cpanfile.snapshot>, | ||||||||||||||||||||||||||||||||||||||||||
| 760 | instead we would run: | ||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | plx --cpanm -ldevel --notest Carton | ||||||||||||||||||||||||||||||||||||||||||
| 763 | plx carton install | ||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | If the goal is to test this against our current development version of another | ||||||||||||||||||||||||||||||||||||||||||
| 766 | library, then we'd also want to run: | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | plx --config libspec add 40otherlib.dir ../Other-Lib/lib | ||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | If we want our ~/perl L<local::lib> available within the plx environment, we | ||||||||||||||||||||||||||||||||||||||||||
| 771 | can add that as the least significant libspec with: | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | plx --config libspec add 00tilde.ll $HOME/perl5 | ||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | At which point, we're ready to go, and can run: | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | plx myapp # to run bin/myapp | ||||||||||||||||||||||||||||||||||||||||||
| 778 | plx t/foo.t # to run one test file | ||||||||||||||||||||||||||||||||||||||||||
| 779 | plx prove # to run all t/*.t test files | ||||||||||||||||||||||||||||||||||||||||||
| 780 | plx -E 'say for @INC' # to run a one liner within the layout | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | To learn everything else plx is capable of, read on to the L</ACTIONS> section | ||||||||||||||||||||||||||||||||||||||||||
| 783 | coming next. | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | Have fun! | ||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | =head1 BOOTSTRAP | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | Under normal circumstances, one would run something like: | ||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | cpanm App::plx | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | However, if you want a self-contained plx script without having a cpan | ||||||||||||||||||||||||||||||||||||||||||
| 794 | installer available, you can run: | ||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | mkdir bin | ||||||||||||||||||||||||||||||||||||||||||
| 797 | wget https://raw.githubusercontent.com/NicholasBHubbard/plx/master/bin/plx-packed -O bin/plx | ||||||||||||||||||||||||||||||||||||||||||
| 798 | chmod +x bin/plx | ||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||
| 800 | to get the current latest packed version. | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | The packed version bundles L<local::lib> and L<File::Which>, and also includes | ||||||||||||||||||||||||||||||||||||||||||
| 803 | a modified C<--cpanm> action that uses an inline C<App::cpanminus>. | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | =head1 ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | C<plx> actions that execute external commands all clear any existing | ||||||||||||||||||||||||||||||||||||||||||
| 808 | environment variables that start with C<PERL> to keep an encapsulated setup | ||||||||||||||||||||||||||||||||||||||||||
| 809 | for commands being run within the layouts - and also set C<PERL5OPT> to | ||||||||||||||||||||||||||||||||||||||||||
| 810 | exclude C<site_perl> (but not C<vendor_perl>) to avoid locally installed | ||||||||||||||||||||||||||||||||||||||||||
| 811 | modules causing unexpected effects. | ||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | Having done so, C<plx> then loads each env config entry and sets those | ||||||||||||||||||||||||||||||||||||||||||
| 814 | variables - then prepends the C<plx> specific entries to both C<PATH> and | ||||||||||||||||||||||||||||||||||||||||||
| 815 | C<PERL5LIB>. You can add env config entries with L</--config>: | ||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | plx --config env add NAME VALUE | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | The changes that will be made to your environment can be output by calling | ||||||||||||||||||||||||||||||||||||||||||
| 820 | the L</--env> command. | ||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | Additionally, environment variable overrides may be provided to the | ||||||||||||||||||||||||||||||||||||||||||
| 823 | L</--cmd>, L</--exec> and L</--perl> commands by providing them in | ||||||||||||||||||||||||||||||||||||||||||
| 824 | C<NAME=VALUE> format: | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | # do not do this, it will be deleted | ||||||||||||||||||||||||||||||||||||||||||
| 827 | PERL_RL=Perl5 plx <something> | ||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | # do this instead, it will provide the environment variable to the command | ||||||||||||||||||||||||||||||||||||||||||
| 830 | plx PERL_RL=Perl5 <something> | ||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | =head1 ACTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||
| 834 | plx --help # Print synopsis | ||||||||||||||||||||||||||||||||||||||||||
| 835 | plx --version # Print plx version | ||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | plx --init <perl> # Initialize layout config for . | ||||||||||||||||||||||||||||||||||||||||||
| 838 | plx --bareinit <perl> # Initialize bare layout config for . | ||||||||||||||||||||||||||||||||||||||||||
| 839 | plx --base # Show layout base dir | ||||||||||||||||||||||||||||||||||||||||||
| 840 | plx --base <base> <action> <args> # Run action with specified base dir | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | plx --perl # Show layout perl binary | ||||||||||||||||||||||||||||||||||||||||||
| 843 | plx --libs # Show layout $PERL5LIB entries | ||||||||||||||||||||||||||||||||||||||||||
| 844 | plx --paths # Show layout additional $PATH entries | ||||||||||||||||||||||||||||||||||||||||||
| 845 | plx --env # Show layout env var changes | ||||||||||||||||||||||||||||||||||||||||||
| 846 | plx --cpanm -llocal --installdeps . # Run cpanm from outside $PATH | ||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | plx --config perl # Show perl binary | ||||||||||||||||||||||||||||||||||||||||||
| 849 | plx --config perl set /path/to/perl # Select exact perl binary | ||||||||||||||||||||||||||||||||||||||||||
| 850 | plx --config perl set perl-5.xx.y # Select perl via $PATH or perlbrew | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | plx --config libspec # Show lib specifications | ||||||||||||||||||||||||||||||||||||||||||
| 853 | plx --config libspec add <name> <path> # Add lib specification | ||||||||||||||||||||||||||||||||||||||||||
| 854 | plx --config libspec del <name> <path> # Delete lib specification | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | plx --config env # Show additional env vars | ||||||||||||||||||||||||||||||||||||||||||
| 857 | plx --config env add <name> <path> # Add env var | ||||||||||||||||||||||||||||||||||||||||||
| 858 | plx --config env del <name> <path> # Delete env var | ||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | plx --exec <cmd> <args> # exec()s with env vars set | ||||||||||||||||||||||||||||||||||||||||||
| 861 | plx --perl <args> # Run perl with args | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | plx --cmd <cmd> <args> # DWIM command: | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | cmd = perl -> --perl <args> | ||||||||||||||||||||||||||||||||||||||||||
| 866 | cmd = -<flag> -> --perl -<flag> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 867 | cmd = some/file -> --perl some/file <args> | ||||||||||||||||||||||||||||||||||||||||||
| 868 | cmd = ./file -> --perl ./file <args> | ||||||||||||||||||||||||||||||||||||||||||
| 869 | cmd = name -> | ||||||||||||||||||||||||||||||||||||||||||
| 870 | exists .plx/cmd/<name> -> --perl .plx/cmd/<name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 871 | exists dev/<name> -> --perl dev/<name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 872 | exists bin/<name> -> --perl bin/<name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 873 | else -> --exec <name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | plx --which <cmd> # Expands --cmd <cmd> without running | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | plx <something> <args> # Shorthand for plx --cmd | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | plx --commands <filter>? # List available commands | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | plx --multi [ <cmd1> <args1> ] [ ... ] # Run multiple actions | ||||||||||||||||||||||||||||||||||||||||||
| 882 | plx --showmulti [ ... ] [ ... ] # Show multiple action running | ||||||||||||||||||||||||||||||||||||||||||
| 883 | plx [ ... ] [ ... ] # Shorthand for plx --multi | ||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | plx --userinit <perl> # Init ~/.plx with ~/perl5 ll | ||||||||||||||||||||||||||||||||||||||||||
| 886 | plx --installself # Installs plx and cpanm into layout | ||||||||||||||||||||||||||||||||||||||||||
| 887 | plx --installenv # Appends plx --env call to .bashrc | ||||||||||||||||||||||||||||||||||||||||||
| 888 | plx --userstrap <perl> # userinit+installself+installenv | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | =head2 --help | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | Prints out the usage information (i.e. the L</SYNOPSIS>) for plx. | ||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | =head2 --init | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | plx --init # resolve 'perl' in $PATH | ||||||||||||||||||||||||||||||||||||||||||
| 897 | plx --init perl # (ditto) | ||||||||||||||||||||||||||||||||||||||||||
| 898 | plx --init 5.28.0 # looks for perl5.28.0 in $PATH | ||||||||||||||||||||||||||||||||||||||||||
| 899 | # or perl-5.28.0 in perlbrew | ||||||||||||||||||||||||||||||||||||||||||
| 900 | plx --init /path/to/some/perl # uses the absolute path directly | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | Initializes the layout. | ||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||
| 904 | If a perl name is passed, attempts to resolve it via C<$PATH> and C<perlbrew> | ||||||||||||||||||||||||||||||||||||||||||
| 905 | and sets the result as the layout perl; if not looks for just C<perl>. | ||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | Creates the following libspec config: | ||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | 25-local.ll local | ||||||||||||||||||||||||||||||||||||||||||
| 910 | 50-devel.ll devel | ||||||||||||||||||||||||||||||||||||||||||
| 911 | 75-lib.dir lib | ||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||
| 913 | =head2 --bareinit | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | Identical to C<--init> but creates no default configs except for C<perl>. | ||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | =head2 --base | ||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | plx --base | ||||||||||||||||||||||||||||||||||||||||||
| 920 | plx --base <base> <action> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | Without arguments, shows the selected base dir - C<plx> finds this by | ||||||||||||||||||||||||||||||||||||||||||
| 923 | checking for a C<.plx> directory in the current directory, and if not tries | ||||||||||||||||||||||||||||||||||||||||||
| 924 | the parent directory, recursively. The search stops either when C<plx> finds | ||||||||||||||||||||||||||||||||||||||||||
| 925 | a C<.git> directory, to avoid accidentally escaping a project repository, or | ||||||||||||||||||||||||||||||||||||||||||
| 926 | at the last directory before the root - i.e. C<plx> will test C</home> but | ||||||||||||||||||||||||||||||||||||||||||
| 927 | not C</>. | ||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||
| 929 | With arguments, specifies a base dir to use, and then invokes the rest of the | ||||||||||||||||||||||||||||||||||||||||||
| 930 | arguments with that base dir selected - so for example one can make a default | ||||||||||||||||||||||||||||||||||||||||||
| 931 | configuration in C<$HOME> available as C<plh> by running: | ||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | plx --init $HOME | ||||||||||||||||||||||||||||||||||||||||||
| 934 | alias plh='plx --base $HOME' | ||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||
| 936 | =head2 --libs | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | Prints the directories that will be added to C<PERL5LIB>, one per line. | ||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | These will include the C<lib/perl5> subdirectory for each C<ll> entry in the | ||||||||||||||||||||||||||||||||||||||||||
| 941 | libspecs, and the directory for each C<dir> entry. | ||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | =head2 --paths | ||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | Prints the directories that will be added to C<PATH>, one per line. | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | These will include the containing directory of the environment's perl binary | ||||||||||||||||||||||||||||||||||||||||||
| 948 | if not already in C<PATH>, followed by the C<bin> directories of any C<ll> | ||||||||||||||||||||||||||||||||||||||||||
| 949 | entries in the libspecs. | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | =head2 --env | ||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | Prints the changes that will be made to your environment variables, in a | ||||||||||||||||||||||||||||||||||||||||||
| 954 | syntax that is (hopefully) correct for your current shell. | ||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | =head2 --cpanm | ||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | plx --cpanm -Llocal --installdeps . | ||||||||||||||||||||||||||||||||||||||||||
| 959 | plx --cpanm -ldevel App::Ack | ||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | Finds the C<cpanm> binary in the C<PATH> that C<plx> was executed I<from>, | ||||||||||||||||||||||||||||||||||||||||||
| 962 | and executes it using the layout's perl binary and environment variables. | ||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||
| 964 | Requires the user to specify a L<local::lib> to install into via C<-l> or | ||||||||||||||||||||||||||||||||||||||||||
| 965 | C<-L> in order to avoid installing modules into unexpected places. | ||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | Note that this action exists primarily for bootstrapping, and if you want | ||||||||||||||||||||||||||||||||||||||||||
| 968 | to use a different installer such as L<App::cpm>, you'd install it with: | ||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | plx --cpanm -ldevel App::cpm | ||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | and then subsequently run e.g. | ||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | plx cpm install App::Ack | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | to install modules. | ||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | =head2 --exec | ||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||
| 980 | plx --exec <command> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||
| 982 | Sets up the layout's environment variables and C<exec>s the command. | ||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||
| 984 | =head2 --perl | ||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | plx --perl | ||||||||||||||||||||||||||||||||||||||||||
| 987 | plx --perl <options> <script> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||
| 989 | Without arguments, sugar for C<--config perl>. | ||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||
| 991 | Otherwise, sets up the layout's environment variables and C<exec>s the | ||||||||||||||||||||||||||||||||||||||||||
| 992 | layout's perl with the given options and arguments. | ||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||
| 994 | =head2 --cmd | ||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | plx --cmd <cmd> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | cmd = perl -> --perl <args> | ||||||||||||||||||||||||||||||||||||||||||
| 999 | cmd = -<flag> -> --perl -<flag> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | cmd = some/file -> --perl some/file <args> | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | cmd = ./file -> --perl ./file <args> | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | cmd = name -> | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | exists .plx/cmd/<name> -> --perl .plx/cmd/<name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | exists dev/<name> -> --perl dev/<name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | exists bin/<name> -> --perl bin/<name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | else -> --exec <name> <args> | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | B<Note>: Much like the C<devel> L<local::lib> is created to allow for the | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | installation of out-of-band dependencies that aren't going to be needed in | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | production, the C<dev> directory is supported to allow for the easy addition | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | of development time only sugar commands. Note that since C<perl> will re-exec | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | anything with a non-perl shebang, one can add wrappers here ala: | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | $ cat dev/prove | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | #!/bin/sh | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | exec prove -j8 "$@" | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||
| 1018 | =head2 --which | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | plx --which <cmd> | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||
| 1022 | Outputs the expanded form of a C<--cmd> invocation without running it. | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||
| 1024 | =head2 --config | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||
| 1026 | plx --config # Show current config | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | plx --config <name> # Show current <name> config | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | plx --config <name> <operation> # Invoke config operation | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | =head3 perl | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | plx --config perl | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | plx --config perl set <spec> | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | If the spec passed to C<set> contains a C</> character, plx assumes that it's | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | an absolute bath and records it as-is. | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | If not, we go a-hunting. | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | First, if the spec begins with a C<5>, we replace it with C<perl5>. | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | Second, we search C<$PATH> for a binary of that name, and record it if so. | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | Third, if the (current) spec begins C<perl5>, we replace it with C<perl-5>. | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||
| 1046 | Fourth, we search C<$PATH> for a C<perlbrew> binary, and ask it if it has a | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | perl named after the spec, and record that if so. | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||
| 1049 | Fifth, we shrug and hope the user can come up with an absolute path next time. | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||
| 1051 | B<Note:> The original spec passed to C<set> is recorded in C<.plx/perl.spec>, | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | so if you intend to share the C<.plx> directory across multiple machines via | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | version control or otherwise, remove/exclude the C<.plx/perl> file and plx | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | will automatically attempt to re-locate the perl on first invocation. | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||
| 1056 | =head3 libspec | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | plx --config libspec | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | plx --config libspec add <name> <spec> | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | plx --config libspec del <name> <spec> | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||
| 1062 | A libspec config entry consists of a name and a spec, and the show output | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | prints them space separated one per line, with enough spaces to make the | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | specs align: | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 25-local.ll local | ||||||||||||||||||||||||||||||||||||||||||
| 1067 | 50-devel.ll devel | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | 75-lib.dir lib | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | The part of the name before the last C<.> is not semantically significant to | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | plx, but is used for asciibetical sorting of the libspec entries to determine | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | in which order to apply them. | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | The part after must be either C<ll> for a L<local::lib>, or C<dir> for a bare | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | L<lib> directory. | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | When loaded, the spec is (if relative) resolved to an absolute path relative | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | to the layout root, then all C<..> entries and symlinks resolved to give a | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | final path used to set up the layout environment. | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | =head3 env | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | plx --config env | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | plx --config env add <name> <value> | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | plx --config env del <name> <value> | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||
| 1087 | Manages additional environment variables, which are set immediately before | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | any environment changes required for the current L</libspec> and L</perl> | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | settings are processed. | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||
| 1091 | =head2 --commands | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||
| 1093 | plx --commands # all commands | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | plx --commands c # all commands starting with c | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | plx --commands /json/ # all commands matching /json/ | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||
| 1097 | Lists available commands, name first, then full path. | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||
| 1099 | If a filter argument is given, treats it as a fixed prefix to filter the | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | command list, unless the filter is C</re/> in which case the slashes are | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | stripped and the filter is treated as a regexp. | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | =head2 --multi | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | plx --multi [ --init ] [ --config perl set 5.28.0 ] | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||
| 1107 | Runs multiple plx commands from a single invocation delimited by C<[ ... ]>. | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | =head2 --showmulti | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | plx --showmulti [ --init ] [ --config perl set 5.28.0 ] | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||
| 1113 | Outputs approximate plx invocations that would be run by C<--multi>. | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | =head2 --userinit | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | Same as C<--init> but assumes C<$HOME> as base and sets up only a single | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | libspec pointing at C<$HOME/perl5>. | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | =head2 --installself | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||
| 1122 | Installs L<App::plx> and L<App::cpanminus> into the highest-numbered | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | L<local::lib> within the layout. | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | =head2 --installenv | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||
| 1127 | (bash only currently) | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||
| 1129 | Appends an eval line to set up the layout environment to the user's bashrc. | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||
| 1131 | =head2 --userstrap | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | Convenience command for C<--userinit> plus C<--installself> plus | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | C<--installenv>. | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||
| 1136 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk> | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||
| 1140 | =head1 MAINTAINER | ||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||
| 1142 | Nicholas B. Hubbard (cpan:NHUBBARD) <nicholashubbard@posteo.net> | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||
| 1144 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||
| 1146 | Nicholas B. Hubbard (cpan:NHUBBARD) <nicholashubbard@posteo.net> | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||
| 1148 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||
| 1150 | Copyright (c) 2020 the App::plx L</AUTHOR>, L</MAINTAINER>, and | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | L</CONTRIBUTORS> as listed above. | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||
| 1153 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||
| 1155 | This library is free software and may be distributed under the same terms | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | as perl itself. | ||||||||||||||||||||||||||||||||||||||||||