| 1 | # ABSTRACT: Wrapper around corelist with subcommands and tab completion | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | package App::pcorelist; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '0.001'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use base 'App::Spec::Run::Cmd'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Text::Table; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Share qw/ dist_dir dist_file /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub module { | ||||||||||||||||||||||||||
|
Subroutine
module: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 0 | my ($self, $run) = @_; | |||||||||||||||||||||||||||
| 16 | 0 | my $options = $run->options; | |||||||||||||||||||||||||||
| 17 | 0 | my $param = $run->parameters; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | my @cmd = qw/ corelist /; | |||||||||||||||||||||||||||
| 20 | 0 | ▶ | if ($options->{all}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | push @cmd, "-a"; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if ($options->{date}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 0 | push @cmd, "-d"; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | 0 | push @cmd, $param->{module}; | |||||||||||||||||||||||||||
| 27 | 0 | system(@cmd); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub perl { | ||||||||||||||||||||||||||
|
Subroutine
perl: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 0 | my ($self, $run) = @_; | |||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($run->options->{release}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | my @cmd = qw/ corelist -r /; | |||||||||||||||||||||||||||
| 34 | 0 | my @out = qx{@cmd}; | |||||||||||||||||||||||||||
| 35 | 0 | shift @out; | |||||||||||||||||||||||||||
| 36 | 0 | shift @out; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($run->options->{raw}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | @out = map { | ||||||||||||||||||||||||||||
| 39 | 0 | (split ' ', $_)[1] . "\n" | |||||||||||||||||||||||||||
| 40 | } @out; | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | say @out; | |||||||||||||||||||||||||||
| 43 | 0 | return; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 0 | my @cmd = qw/ corelist -v /; | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($run->options->{raw}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | my @out = qx{@cmd}; | |||||||||||||||||||||||||||
| 48 | 0 | shift @out; | |||||||||||||||||||||||||||
| 49 | 0 | shift @out; | |||||||||||||||||||||||||||
| 50 | 0 | say @out; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | else { | ||||||||||||||||||||||||||||
| 53 | 0 | system(@cmd); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub diff { | ||||||||||||||||||||||||||
|
Subroutine
diff: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 0 | my ($self, $run) = @_; | |||||||||||||||||||||||||||
| 59 | 0 | my $options = $run->options; | |||||||||||||||||||||||||||
| 60 | 0 | my $param = $run->parameters; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | my @cmd = (qw/ corelist --diff /, $param->{perl1}, $param->{perl2}); | |||||||||||||||||||||||||||
| 63 | 0 | chomp(my @out = qx{@cmd}); | |||||||||||||||||||||||||||
| 64 | 0 | my @result; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($options->{added} or $options->{removed}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options->{"added"} or $options->{"removed"}
MC/DC0%0/2
$options->{"added"} or $options->{"removed"}
$options->{"added"}
$options->{"removed"}
Truth table0%0/3
A or B
A= $options->{"added"}B= $options->{"removed"}
| |||||||||||||||||||||||||||||
| 66 | 0 | for my $line (@out) { | |||||||||||||||||||||||||||
| 67 | 0 | my ($mod, $v1, $v2) = split ' ', $line; | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ($options->{added} and $v1 =~ m/absent/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options->{"added"} and $v1 =~ /absent/
MC/DC0%0/2
$options->{"added"} and $v1 =~ /absent/
$options->{"added"}
$v1 =~ /absent/
Truth table0%0/3
A and B
A= $options->{"added"}B= $v1 =~ /absent/
| |||||||||||||||||||||||||||||
| 69 | 0 | push @result, $line; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($options->{removed} and $v2 =~ m/absent/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options->{"removed"} and $v2 =~ /absent/
MC/DC0%0/2
$options->{"removed"} and $v2 =~ /absent/
$options->{"removed"}
$v2 =~ /absent/
Truth table0%0/3
A and B
A= $options->{"removed"}B= $v2 =~ /absent/
| |||||||||||||||||||||||||||||
| 72 | 0 | push @result, $line; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | else { | ||||||||||||||||||||||||||||
| 77 | 0 | @result = @out; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | 0 | for my $item (@result) { | |||||||||||||||||||||||||||
| 80 | 0 | my ($mod, $v1, $v2) = split ' ', $item; | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($v1 =~ m/absent/) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 82 | 0 | say $run->colored(out => ['green'], $item); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | elsif ($v2 =~ m/absent/) { | ||||||||||||||||||||||||||||
| 85 | 0 | say $run->colored(out => ['red'], $item); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||
| 88 | 0 | say $item; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub features { | ||||||||||||||||||||||||||
|
Subroutine
features: not called CC=12 SCAR=48.5
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 0 | my ($self, $run) = @_; | |||||||||||||||||||||||||||
| 95 | 0 | my $param = $run->parameters; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 1 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 98 | 0 | require feature; | |||||||||||||||||||||||||||
| 99 | 0 | my $param_feature = $param->{feature}; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | my %feature2version; | |||||||||||||||||||||||||||
| 102 | 0 | my @bundles = map { $_->[0] } | |||||||||||||||||||||||||||
| 103 | 0 | sort { $b->[1] <=> $a->[1] } | |||||||||||||||||||||||||||
| 104 | 0 | map { [$_, _numify_version($_)] } | |||||||||||||||||||||||||||
| 105 | 0 | grep { not /[^0-9.]/ } | |||||||||||||||||||||||||||
| 106 | keys %feature::feature_bundle; | ||||||||||||||||||||||||||||
| 107 | 0 | for my $version (@bundles) { | |||||||||||||||||||||||||||
| 108 | 0 | my $f = $feature::feature_bundle{$version}; | |||||||||||||||||||||||||||
| 109 | $feature2version{$_} = $version =~ /^\d\.\d+$/ ? "$version.0" : $version | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | for @$f; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 0 | my @features = sort keys %feature2version; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | # allow internal feature names, just in case someone gives us __SUB__ | ||||||||||||||||||||||||||||
| 115 | # instead of current_sub. | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | while (my ($name, $internal) = each %feature::feature) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | $internal =~ s/^feature_//; | |||||||||||||||||||||||||||
| 118 | $feature2version{$internal} = $feature2version{$name} | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if $feature2version{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if (@$param_feature) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | for my $feature (@$param_feature) { | |||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ($feature2version{ $feature }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | say sprintf "feature '%s' was first released with the perl" | ||||||||||||||||||||||||||||
| 126 | . " %s feature bundle", | ||||||||||||||||||||||||||||
| 127 | 0 | $feature, $feature2version{ $feature }; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||
| 130 | 0 | say sprintf "feature '%s' doesn't exist (or so I think)", | |||||||||||||||||||||||||||
| 131 | $feature; | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | else { | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($run->options->{raw}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | say for @features; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | else { | ||||||||||||||||||||||||||||
| 140 | 0 | my $tb = Text::Table->new; | |||||||||||||||||||||||||||
| 141 | 0 | for my $f (@features) { | |||||||||||||||||||||||||||
| 142 | 0 | $tb->add($f, $feature2version{ $f }); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | say $tb; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub _numify_version { | ||||||||||||||||||||||||||
|
Subroutine
_numify_version: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 150 | 0 | my $ver = shift; | |||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($ver =~ /\..+\./) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | $ver = version->new($ver)->numify; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | 0 | $ver += 0; | |||||||||||||||||||||||||||
| 155 | 0 | return $ver; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub modules { | ||||||||||||||||||||||||||
|
Subroutine
modules: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 159 | 0 | my ($self, $run) = @_; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | my %modules; | |||||||||||||||||||||||||||
| 162 | 0 | require Module::CoreList; | |||||||||||||||||||||||||||
| 163 | 0 | for my $v (keys %Module::CoreList::delta) { | |||||||||||||||||||||||||||
| 164 | 0 | my $changes = $Module::CoreList::delta{ $v }; | |||||||||||||||||||||||||||
| 165 | 0 | my $changed = $changes->{changed}; | |||||||||||||||||||||||||||
| 166 | 0 | my $removed = $changes->{removed}; | |||||||||||||||||||||||||||
| 167 | 0 | @modules{ (keys %$changed), (keys %$removed) } = (); | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | 0 | say for sort keys %modules; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub completion_dir { | ||||||||||||||||||||||||||
|
Subroutine
completion_dir: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 173 | 0 | my $sharedir = dist_dir('App-pcorelist'); | |||||||||||||||||||||||||||
| 174 | 0 | my $completion_dir = dist_file("App-pcorelist", 'completion'); | |||||||||||||||||||||||||||
| 175 | 0 | printf +("%-21s: %30s\n" x 4), | |||||||||||||||||||||||||||
| 176 | 'Shared directory', $sharedir, | ||||||||||||||||||||||||||||
| 177 | 'Completion directory', $completion_dir, | ||||||||||||||||||||||||||||
| 178 | 'zsh completion', "$completion_dir/zsh/_pcorelist", | ||||||||||||||||||||||||||||
| 179 | 'bash completion', "$completion_dir/bash/pcorelist.bash"; | ||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 1 | 1; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | __END__ | ||||||||||||||||||||||||||||