| 1 | package Getopt::Yath::Instance; | ||||||||||||||||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '2.000008'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Getopt::Yath::Util qw/mod2file/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Getopt::Yath::Option; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Getopt::Yath::Settings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Getopt::Yath::Term qw/USE_COLOR color/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | use Getopt::Yath::HashBase qw{ | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | <options <included | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | <posts | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | <stops | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | <class | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | +dedup | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | +options_groups_cache | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | +options_map_cache | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | +cache_key | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | category_sort_map | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=5 SCAR=17.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | $self->{+OPTIONS} //= []; # List of option instances | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"options"} //= []
MC/DC0%0/1
$self->{"options"} //= []
$self->{"options"}
Truth table50%1/2
A
A= $self->{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | $self->{+POSTS} //= {}; # weight => {...} | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"posts"} //= {}
MC/DC0%0/1
$self->{"posts"} //= {}
$self->{"posts"}
Truth table50%1/2
A
A= $self->{"posts"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | $self->{+INCLUDED} //= {}; # type => [$inst], | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"included"} //= {}
MC/DC0%0/1
$self->{"included"} //= {}
$self->{"included"}
Truth table50%1/2
A
A= $self->{"included"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | $self->{+CATEGORY_SORT_MAP} //= {'NO CATEGORY - FIX ME' => 99999}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"category_sort_map"} //= {"NO CATEGORY - FIX ME", 99999}
MC/DC0%0/1
$self->{"category_sort_map"} //= {"NO CATEGORY - FIX ME", 99999}
$self->{"category_sort_map"}
Truth table50%1/2
A
A= $self->{"category_sort_map"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | $self->{+DEDUP} = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | sub add_option { | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_option: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $option = Getopt::Yath::Option->create(trace => [caller()], @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return $self->_option($option); | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub add_post_process { | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_post_process: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $self->_post([caller()], @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sub _post { | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_post: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | my ($caller, $weight, $applicable, $cb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | $weight //= 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$weight //= 0
MC/DC0%0/1
$weight //= 0
$weight
Truth table50%1/2
A
A= $weight
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | return if $self->{+DEDUP}->{$cb}++; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | push @{$self->{+POSTS}->{$weight}} => {caller => $caller, weight => $weight, applicable => $applicable, callback => $cb}; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | sub include { | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
include: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my ($other, $list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return unless $other; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | return if $self->{+DEDUP}->{$other}++; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | push @{$self->included->{ref($other)} //= []} => $other; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->included->{ref $other} //= []
MC/DC0%0/1
$self->included->{ref $other} //= []
$self->included->{ref $other}
Truth table0%0/2
A
A= $self->included->{ref $other}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (my $other_include = $other->included) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | for my $key (keys %{$other_include}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | push @{$self->included->{$key}} => @{$other_include->{$key} // []}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$other_include->{$key} // []
MC/DC0%0/1
$other_include->{$key} // []
$other_include->{$key}
Truth table0%0/2
A
A= $other_include->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ($list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my %want = map {$_ => 1} @$list; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $self->_option($_) for grep { $want{$_->title} || $want{$_->field} || $want{$_->name} } @{$other->options}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$want{$_->title} or $want{$_->field}
MC/DC0%0/2
$want{$_->title} or $want{$_->field}
$want{$_->title}
$want{$_->field}
Truth table0%0/3
A or B
A= $want{$_->title}B= $want{$_->field}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->_option($_) for @{$other->options}; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | for my $set (values %{$other->posts}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | for my $post (@$set) { | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->_post(@{$post}{qw/caller weight applicable callback/}); | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $self->clear_cache; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | sub _option { | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_option: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 15 | my ($option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 15 | ▶ | my $options = $self->{+OPTIONS} //= []; # List of option instances | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"options"} //= []
MC/DC0%0/1
$self->{"options"} //= []
$self->{"options"}
Truth table50%1/2
A
A= $self->{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 15 | ▶ | return if $self->{+DEDUP}->{$option}++; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 15 | push @{$options} => $option; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | sub clear_cache { | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_cache: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | delete $self->{+OPTIONS_GROUPS_CACHE}; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | delete $self->{+OPTIONS_MAP_CACHE}; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | delete $self->{+CACHE_KEY}; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | sub check_cache { | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_cache: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $options = $self->options; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $new_key = @$options; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $old_key = $self->{+CACHE_KEY} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"cache_key"} //= 0
MC/DC0%0/1
$self->{"cache_key"} //= 0
$self->{"cache_key"}
Truth table0%0/2
A
A= $self->{"cache_key"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | return 1 if $old_key == $new_key; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $self->clear_cache(); | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $self->{+CACHE_KEY} = $new_key; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | sub have_group { | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
have_group: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | return 1 if $self->option_groups->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | sub option_groups { | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
option_groups: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my ($in_options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $options; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ($in_options) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $options = $in_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $options = $self->options; | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | return $self->{+OPTIONS_GROUPS_CACHE} | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if $self->{+OPTIONS_GROUPS_CACHE} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"options_groups_cache"} and $self->check_cache
MC/DC0%0/2
$self->{"options_groups_cache"} and $self->check_cache
$self->{"options_groups_cache"}
$self->check_cache
Truth table0%0/3
A and B
A= $self->{"options_groups_cache"}B= $self->check_cache
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | && $self->check_cache(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $groups = { map {($_->group() => 1)} @$options }; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return $groups if $in_options; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return $self->{+OPTIONS_GROUPS_CACHE} = $groups; | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub option_map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 64 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
option_map: called CC=10 SCAR=31.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 64 | my ($in_options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 64 | my $options; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 64 | ▶ | if ($in_options) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 64 | $options = $in_options; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $options = $self->options; | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | return $self->{+OPTIONS_MAP_CACHE} | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if $self->{+OPTIONS_MAP_CACHE} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"options_map_cache"} and $self->check_cache
MC/DC0%0/2
$self->{"options_map_cache"} and $self->check_cache
$self->{"options_map_cache"}
$self->check_cache
Truth table0%0/3
A and B
A= $self->{"options_map_cache"}B= $self->check_cache
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | && $self->check_cache(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 64 | my $map = { | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | custom_match => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # --whatever => $option | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 64 | for my $option (@$options) { | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 452 | ▶ | push @{$map->{custom_match}} => $option->custom_matches | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | if $option->can('custom_matches'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 452 | for my $form (keys %{$option->forms}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1435 | ▶ | if (my $existing = $map->{$form}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | croak "Option form '$form' defined twice, first in '" . $existing->trace_string . "' and again in '" . $option->trace_string . "'" if $existing ne $option; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1435 | $map->{$form} = $option; | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 64 | ▶ | return $map if $in_options; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return $self->{+OPTIONS_MAP_CACHE} = $map; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | sub process_args { | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 64 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_args: called CC=88 SCAR=54.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 64 | my ($args, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 64 | ▶ | croak "Must provide an argv arrayref" unless $args && ref($args) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args and ref $args eq "ARRAY"
MC/DC0%0/2
$args and ref $args eq "ARRAY"
$args
ref $args eq "ARRAY"
Truth table33%1/3
A and B
A= $argsB= ref $args eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 64 | my $argv = [@$args]; # Make a copy | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 64 | ▶ | my $settings = $params{settings} // Getopt::Yath::Settings->new({}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$params{"settings"} // "Getopt::Yath::Settings"->new({})
MC/DC0%0/2
$params{"settings"} // "Getopt::Yath::Settings"->new({})
$params{"settings"}
"Getopt::Yath::Settings"->new({})
Truth table33%1/3
A // B
A= $params{"settings"}B= "Getopt::Yath::Settings"->new({})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 64 | ▶ | my $stops = $params{stops} // []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params{"stops"} // []
MC/DC100%1/1
$params{"stops"} // []
$params{"stops"}
Truth table100%2/2
A
A= $params{"stops"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 64 | ▶ | my $groups = $params{groups} // {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{"groups"} // {}
MC/DC0%0/1
$params{"groups"} // {}
$params{"groups"}
Truth table50%1/2
A
A= $params{"groups"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 64 | ▶ | $stops = { map { ($_ => 1) } @$stops } if $stops && ref($stops) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$stops and ref $stops eq "ARRAY"
MC/DC0%0/2
$stops and ref $stops eq "ARRAY"
$stops
ref $stops eq "ARRAY"
Truth table33%1/3
A and B
A= $stopsB= ref $stops eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 64 | ▶ | my $options = [ grep { $_->is_applicable($self, $settings) } @{$self->options // []} ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->options // []
MC/DC0%0/1
$self->options // []
$self->options
Truth table50%1/2
A
A= $self->options
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 64 | my @skip; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | my $state = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | settings => $settings, | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | skipped => \@skip, | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | remains => $argv, | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | env => $params{env} // {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | cleared => $params{cleared} // {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | modules => $params{modules} // {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 64 | ▶ | stop => undef, | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$params{"env"} // {}
$params{"cleared"} // {}
$params{"modules"} // {}
MC/DC0%0/1
$params{"env"} // {}
$params{"env"}
MC/DC0%0/1
$params{"cleared"} // {}
$params{"cleared"}
MC/DC0%0/1
$params{"modules"} // {}
$params{"modules"}
Truth table50%1/2
A
A= $params{"env"}
Truth table50%1/2
A
A= $params{"cleared"}
Truth table50%1/2
A
A= $params{"modules"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 64 | for my $opt (@$options) { | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 475 | my $group = $settings->group($opt->group, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 475 | my $ref = $group->option_ref($opt->field, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 475 | ▶ | unless(defined ${$ref}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 475 | my $val = $opt->get_initial_value($settings); | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 475 | my $rt = ref($val); | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 475 | ▶ | if (!defined($val)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 329 | $val = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | elsif ($rt) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 86 | ▶ | $val = [ $rt eq 'ARRAY' ? @$val : %$val ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 60 | $val = [$val]; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 475 | $opt->trigger(action => 'initialize', ref => $ref, val => $val, state => $state, options => $self, settings => $settings, group => $group); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 475 | $opt->add_value($ref, @$val); | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 475 | $opt->init_settings($state, $settings, $group, $ref); | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 64 | ▶ | my $invalid = $params{invalid_opt_callback} // sub { die "'$_[0]' is not a valid option.\n" }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$params{"invalid_opt_callback"} // sub {
die "'$_[0]' is not a valid option.\n";
}
MC/DC0%0/2
$params{"invalid_opt_callback"} // sub {
die "'$_[0]' is not a valid option.\n";
}
$params{"invalid_opt_callback"}
sub {
die "'$_[0]' is not a valid option.\n";
}
Truth table33%1/3
A // B
A= $params{"invalid_opt_callback"}B= sub {
die "'$_[0]' is not a valid option.\n";
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 64 | my $parse_group; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | $parse_group = sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $end = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $group = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | while (@$argv) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $arg = shift(@$argv); | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | return $group if $arg eq $end; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if (my $nest = $groups->{$arg}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $arg = $parse_group->($nest); | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | push @$group => $arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | die "Could not find end token '$end' before end of arguments.\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | 64 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 64 | ▶ | while (@$argv) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 64 | my $map = $self->option_map($options); | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 64 | my $base = shift @$argv; | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 64 | ▶ | if (my $end = $groups->{$base}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | push @skip => $parse_group->($end); | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 64 | ▶ | if ($stops->{$base}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | $state->{stop} = $base; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 63 | ▶ | if ($base !~ m/^-/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | ▶ | if ($params{stop_at_non_opts}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $state->{stop} = $base; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | ▶ | if ($params{skip_non_opts}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | push @skip => $base; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | $invalid->($base); | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 60 | my ($first, $set, $arg, $opt, $delta); | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 60 | ▶ | if ($base =~ m/^(-[^-])(=?)(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 33 | my ($other, $eq); | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | 33 | ($first, $set, $other) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 33 | ▶ | if ($opt = $map->{$first}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 33 | ▶ | if ($opt->allows_shortval && ($set || $other)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
$opt->allows_shortval and $set || $other
$set or $other
MC/DC100%3/3
$opt->allows_shortval and $set || $other
$opt->allows_shortval
$set
$other
Truth table100%4/4
A and B or C
A= $opt->allows_shortvalB= $setC= $other
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 10 | $set = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | 10 | $arg = $other; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | elsif ($set) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 4 | $arg = $other; | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 19 | ▶ | unshift @$argv => "-$other" if $other; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 27 | ($first, $set, $arg) = split(/(=)/, $base, 2); | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | 27 | $opt = $map->{$first}; | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 60 | ▶ | unless ($opt) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | ▶ | if (my $list = $map->{custom_match}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | for my $match (@$list) { | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ($opt, $delta, $arg) = $match->($base, $state); | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | next unless $opt; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $set = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 60 | ▶ | die "Use of 'arg=val' form without a value is not valid in option '$base'.\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$set and not defined $arg
MC/DC0%0/2
$set and not defined $arg
$set
not defined $arg
Truth table66%2/3
A and not(B)
A= $setB= not defined $arg
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | if $set && !defined($arg); | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 60 | ▶ | unless ($opt) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | ▶ | if ($params{skip_invalid_opts}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | push @skip => $base; | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | ▶ | if ($params{stop_at_invalid_opts}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $state->{stop} = $base; | |||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 1 | $invalid->($base); | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 58 | ▶ | die "Use of 'arg=val' form is not allowed in option '$base'. Arguments are not allowed for this option type.\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$set and not $opt->allows_arg
MC/DC100%2/2
$set and not $opt->allows_arg
$set
not $opt->allows_arg
Truth table100%3/3
A and not(B)
A= $setB= not $opt->allows_arg
| |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | if $set && !$opt->allows_arg; | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 57 | ▶ | $delta //= $opt->forms->{$first}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$delta //= $opt->forms->{$first}
MC/DC0%0/2
$delta //= $opt->forms->{$first}
$delta
$opt->forms->{$first}
Truth table33%1/3
A //= B
A= $deltaB= $opt->forms->{$first}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 57 | ▶ | $state->{modules}->{$opt->module}++ unless $opt->no_module; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 57 | my $group_name = $opt->group; | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | 57 | my $field_name = $opt->field; | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | 57 | my $group = $settings->group($group_name, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | 57 | my $ref = $group->option_ref($field_name, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 57 | ▶ | if ($delta < 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 12 | $opt->clear_field($ref); | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | 12 | $opt->trigger(action => 'clear', ref => $ref, val => undef, state => $state, options => $self, settings => $settings, group => $group); | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | 12 | $state->{cleared}->{$group_name}->{$field_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | 12 | ▶ | next unless $set; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 45 | ▶ | delete $state->{cleared}->{$group_name}->{$field_name} if $state->{cleared}->{$group_name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 45 | ▶ | if ($opt->requires_arg && !$set) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opt->requires_arg and not $set
MC/DC100%2/2
$opt->requires_arg and not $set
$opt->requires_arg
not $set
Truth table100%3/3
A and not(B)
A= $opt->requires_argB= not $set
| |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 9 | ▶ | die "No argument provided to '$first'.\n" unless @$argv; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 8 | $arg = shift(@$argv); | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 44 | ▶ | if ($arg) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 23 | ▶ | if (my $end = $groups->{$arg}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $arg = $parse_group->($end); | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 44 | ▶ | if (ref($arg) && @$arg > 1 && !$opt->allows_list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $arg and @$arg > 1 and not $opt->allows_list
ref $arg and @$arg > 1
MC/DC0%0/3
ref $arg and @$arg > 1 and not $opt->allows_list
ref $arg
@$arg > 1
not $opt->allows_list
Truth table25%1/4
A and B and not(C)
A= ref $argB= @$arg > 1C= not $opt->allows_list
| |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | die "Option '$first' cannot take multiple values, got: [" . join(', ' => @$arg) . "].\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 44 | my $from = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | 44 | my @val; | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | 44 | ▶ | if (defined $arg) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 24 | $from = 'arg'; | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 24 | ▶ | @val = $opt->normalize_value(ref($arg) ? @$arg : $arg); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | elsif ($opt->allows_autofill) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 7 | $from = 'autofill'; | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | 7 | @val = $opt->get_autofill_value($settings); | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 13 | $from = 'no_arg'; | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | 13 | @val = $opt->no_arg_value($settings); | |||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 44 | ▶ | if ($opt->mod_adds_options) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my ($class) = @val; | |||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | require(mod2file($class)); | |||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if ($class->can('options')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if (my $add = $class->options) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $self->include($add); | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 44 | $opt->trigger(action => 'set', ref => $ref, val => \@val, state => $state, options => $self, settings => $settings, group => $group, set_from => $from); | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | 44 | my @bad = $opt->check_value(\@val); | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | 44 | ▶ | if (@bad) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | die "Invalid value(s) for option '$first': " . join(', ' => map {defined($_) ? "'$_'" : 'undef' } @bad) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 44 | $opt->add_value($ref, @val); | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 59 | for my $opt (@$options) { | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | 447 | my $group_name = $opt->group; | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | 447 | my $field_name = $opt->field; | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | 447 | my $group = $settings->group($group_name, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | 447 | my $ref = $group->option_ref($field_name, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # Do not set the default if the --no-OPT form was used. | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 447 | ▶ | next if $state->{cleared} && $state->{cleared}->{$group_name} && $state->{cleared}->{$group_name}->{$field_name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$state->{"cleared"} and $state->{"cleared"}{$group_name} and $state->{"cleared"}{$group_name}{$field_name}
$state->{"cleared"} and $state->{"cleared"}{$group_name}
MC/DC66%2/3
$state->{"cleared"} and $state->{"cleared"}{$group_name} and $state->{"cleared"}{$group_name}{$field_name}
$state->{"cleared"}
$state->{"cleared"}{$group_name}
$state->{"cleared"}{$group_name}{$field_name}
Truth table75%3/4
A and B and C
A= $state->{"cleared"}B= $state->{"cleared"}{$group_name}C= $state->{"cleared"}{$group_name}{$field_name}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 437 | ▶ | next if $opt->is_populated($ref); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 354 | $opt->add_value($ref, $opt->get_default_value($settings)); | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 59 | ▶ | unless ($params{skip_posts}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 59 | for my $weight (sort { $a <=> $b } keys %{$self->{+POSTS}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 430 | 9 | for my $set (@{$self->{+POSTS}->{$weight}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | 12 | ▶ | next if $set->{applicable} && !$set->{applicable}->($set, $self, $settings); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$set->{"applicable"} and not $set->{"applicable"}->($set, $self, $settings)
MC/DC0%0/2
$set->{"applicable"} and not $set->{"applicable"}->($set, $self, $settings)
$set->{"applicable"}
not $set->{"applicable"}->($set, $self, $settings)
Truth table33%1/3
A and not(B)
A= $set->{"applicable"}B= not $set->{"applicable"}->($set, $self, $settings)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 12 | $set->{callback}->($self, $state); | |||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 59 | for my $opt (@$options) { | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | 447 | my $group = $settings->group($opt->group, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 439 | 447 | my $ref = $group->option_ref($opt->field, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 447 | ▶ | for my $env (@{$opt->clear_env_vars // []}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->clear_env_vars // []
MC/DC100%1/1
$opt->clear_env_vars // []
$opt->clear_env_vars
Truth table100%2/2
A
A= $opt->clear_env_vars
| |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 12 | $state->{env}->{$env} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 443 | 12 | ▶ | delete $ENV{$env} unless $params{no_set_env}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 447 | $opt->finalize_settings($state, $settings, $group, $ref); | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 447 | ▶ | next unless $opt->can_set_env; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 367 | ▶ | my $to_set = $opt->set_env_vars or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 12 | ▶ | next unless @$to_set; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 12 | ▶ | next unless $opt->is_populated($ref); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 9 | for my $name (@$to_set) { | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | 9 | my $env = "$name"; | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | 9 | $env =~ s/^(!)//; | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 9 | my $neg = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | 9 | ▶ | my @val = $opt->get_env_value($env => $ref) or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 9 | ▶ | if (@val > 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $title = $opt->title; | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | my $trace = $opt->trace // ['', 'unknown', 'n/a']; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opt->trace // ["", "unknown", "n/a"]
MC/DC0%0/1
$opt->trace // ["", "unknown", "n/a"]
$opt->trace
Truth table0%0/2
A
A= $opt->trace
| |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | die "Option '$title' defined in $trace->[1] line $trace->[2] returned more than one value when get_env_value($env) was called.\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 9 | my $setval = $val[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | 9 | ▶ | $setval = $setval ? 0 : 1 if $neg; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 9 | $state->{env}->{$env} = $val[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | 9 | ▶ | $ENV{$env} = $val[0] unless $params{no_set_env}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 59 | return $state; | |||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | my %DOC_FORMATS = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 'cli' => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 'cli_docs', # Method to call on opt | ||||||||||||||||||||||||||||||||||||||||||||||
| 480 | "\n", # how to join lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | ▶ | sub { $_[4] ? "\n" . color('bold underline white') . $_[1] . color('reset') . " ($_[3])" : "\n$_[1] ($_[3])" }, # how to render the category | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 14 | ▶ | sub { $_[0] =~ s/^/ /mg; "$_[0]\n" }, # transform the value from the opt | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ▶ | sub { }, # add this at the end | |||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 'pod' => [ | ||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 'pod_docs', # Method to call on opt | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | "\n\n", # how to join lines | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | ▶ | sub { ($_[0] ? ("=back") : (), "=head$_[2] $_[1]", "=over 4") }, # how to render the category | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 14 | ▶ | sub { $_[0] }, # transform the value from the opt | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | ▶ | sub { $_[0] ? ("=back\n") : () }, # add this at the end | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | ], | |||||||||||||||||||||||||||||||||||||||||||||
| 492 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||
| 494 | sub docs { | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
docs: called CC=14 SCAR=28.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | my ($format, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 2 | ▶ | $params{color} //= USE_COLOR() && -t STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$params{"color"} //= -t STDOUT
MC/DC0%0/2
$params{"color"} //= -t STDOUT
$params{"color"}
-t STDOUT
Truth table33%1/3
A //= B
A= $params{"color"}B= -t STDOUT
| |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | my $settings = $params{settings}; | |||||||||||||||||||||||||||||||||||||||||||||
| 501 | 2 | ▶ | my $opts = [ grep { $params{applicable} || $_->is_applicable($self, $settings) } @{$self->options // []} ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->options // []
MC/DC0%0/1
$self->options // []
$self->options
Truth table50%1/2
A
A= $self->options
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | ▶ | $format //= "UNDEFINED"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$format //= "UNDEFINED"
MC/DC0%0/1
$format //= "UNDEFINED"
$format
Truth table50%1/2
A
A= $format
| |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | ▶ | my $fset = $DOC_FORMATS{$format} or croak "Invalid documentation format '$format'"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | my ($fmeth, $join, $fcat, $ftrans, $fend) = @$fset; | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 2 | ▶ | return unless $opts; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 2 | ▶ | return unless @$opts; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 2 | my @render = @$opts; | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 2 | ▶ | @render = grep { $_->group eq $params{group} } @render if $params{group}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 2 | ▶ | return "\n\n!! Invalid option group: $params{group} !!" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | unless @render; | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 2 | @render = sort { $self->doc_sort_ops($a, $b) } @render; | |||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||
| 521 | my $cat; | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 2 | for my $opt (@render) { | |||||||||||||||||||||||||||||||||||||||||||||
| 523 | 28 | ▶ | if (!$cat || $opt->category ne $cat) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $cat or $opt->category ne $cat
MC/DC50%1/2
not $cat or $opt->category ne $cat
not $cat
$opt->category ne $cat
Truth table66%2/3
not(A) or B
A= not $catB= $opt->category ne $cat
| |||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2 | push @out => $fcat->($cat, $opt->category, $params{head}, $opt->group, $params{color}); | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | $cat = $opt->category; | |||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 28 | my $help = $opt->$fmeth(%params); | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | 28 | push @out => $ftrans->($help); | |||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 2 | push @out => $fend->($cat); | |||||||||||||||||||||||||||||||||||||||||||||
| 533 | 2 | s/[ \t]+$//gm for @out; | |||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 2 | return join $join => @out; | |||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | sub doc_sort_ops { | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 74 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doc_sort_ops: called CC=12 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 74 | my ($a, $b, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 74 | my $map = $self->{+CATEGORY_SORT_MAP}; | |||||||||||||||||||||||||||||||||||||||||||||
| 543 | 74 | ▶ | my $aw = $map->{$a->category} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$map{$a->category} || 0
MC/DC0%0/1
$$map{$a->category} || 0
$$map{$a->category}
Truth table50%1/2
A
A= $$map{$a->category}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 74 | ▶ | my $bw = $map->{$b->category} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$map{$b->category} || 0
MC/DC0%0/1
$$map{$b->category} || 0
$$map{$b->category}
Truth table50%1/2
A
A= $$map{$b->category}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 74 | my $ret = $aw <=> $bw; | |||||||||||||||||||||||||||||||||||||||||||||
| 547 | 74 | ▶ | if ($params{group_first}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | $ret ||= $a->group cmp $b->group; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ret ||= $a->group cmp $b->group
MC/DC0%0/2
$ret ||= $a->group cmp $b->group
$ret
$a->group cmp $b->group
Truth table0%0/3
A ||= B
A= $retB= $a->group cmp $b->group
| |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | $ret ||= $a->category cmp $b->category; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ret ||= $a->category cmp $b->category
MC/DC0%0/2
$ret ||= $a->category cmp $b->category
$ret
$a->category cmp $b->category
Truth table0%0/3
A ||= B
A= $retB= $a->category cmp $b->category
| |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 551 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 74 | ▶ | $ret ||= $a->category cmp $b->category; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ret ||= $a->category cmp $b->category
MC/DC0%0/2
$ret ||= $a->category cmp $b->category
$ret
$a->category cmp $b->category
Truth table33%1/3
A ||= B
A= $retB= $a->category cmp $b->category
| |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 74 | ▶ | $ret ||= $a->group cmp $b->group; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ret ||= $a->group cmp $b->group
MC/DC0%0/2
$ret ||= $a->group cmp $b->group
$ret
$a->group cmp $b->group
Truth table33%1/3
A ||= B
A= $retB= $a->group cmp $b->group
| |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 74 | ▶ | $ret ||= ($a->prefix || '') cmp ($b->prefix || ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition42%3/7
$ret ||= ($a->prefix || "") cmp ($b->prefix || "")
$a->prefix || ''
$b->prefix || ''
MC/DC0%0/2
$ret ||= ($a->prefix || "") cmp ($b->prefix || "")
$ret
$a->prefix
MC/DC0%0/1
$b->prefix || ''
$b->prefix
Truth table33%1/3
A ||= B
A= $retB= $a->prefix
Truth table50%1/2
A
A= $b->prefix
| |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 74 | ▶ | $ret ||= $a->name cmp $b->name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ret ||= $a->name cmp $b->name
MC/DC0%0/2
$ret ||= $a->name cmp $b->name
$ret
$a->name cmp $b->name
Truth table33%1/3
A ||= B
A= $retB= $a->name cmp $b->name
| |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 74 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||