| 1 | package App::Easer::V1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 22 | ▶ | use v5.24; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 22 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 22 | ▶ | use experimental qw< signatures >; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 22 | ▶ | no warnings qw< experimental::signatures >; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 22 | { our $VERSION = '2.016' } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 22 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 22 | our @EXPORT_OK = qw< d run appeaser_api >; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 103 | ▶ | sub add_auto_commands ($application) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_auto_commands: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 103 | my $commands = $application->{commands}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | $commands->{help} //= { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 103 | ▶ | name => 'help', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$commands->{"help"} //= {"name", "help", "supports", ["help"], "help", "print a help message", "description", "print help for (sub)command", "allow-residual-options", 0, "leaf", 1, "execute", \&App::Easer::V1::stock_help}
MC/DC100%1/1
$commands->{"help"} //= {"name", "help", "supports", ["help"], "help", "print a help message", "description", "print help for (sub)command", "allow-residual-options", 0, "leaf", 1, "execute", \&App::Easer::V1::stock_help}
$commands->{"help"}
Truth table100%2/2
A
A= $commands->{"help"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | supports => ['help'], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | help => 'print a help message', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | description => 'print help for (sub)command', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 'allow-residual-options' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | leaf => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | execute => \&stock_help, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | $commands->{commands} //= { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 103 | ▶ | name => 'commands', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$commands->{"commands"} //= {"name", "commands", "supports", ["commands"], "help", "list sub-commands", "description", "Print list of supported sub-commands", "allow-residual-options", 0, "leaf", 1, "execute", \&App::Easer::V1::stock_commands}
MC/DC100%1/1
$commands->{"commands"} //= {"name", "commands", "supports", ["commands"], "help", "list sub-commands", "description", "Print list of supported sub-commands", "allow-residual-options", 0, "leaf", 1, "execute", \&App::Easer::V1::stock_commands}
$commands->{"commands"}
Truth table100%2/2
A
A= $commands->{"commands"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | supports => ['commands'], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | help => 'list sub-commands', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | description => 'Print list of supported sub-commands', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 'allow-residual-options' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | leaf => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | execute => \&stock_commands, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 103 | return $application; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } ## end sub add_auto_commands ($application) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | sub appeaser_api { return 'V1' } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
appeaser_api: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 183 | ▶ | sub collect ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 183 | my @sequence; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 183 | my $config = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 183 | my @residual_args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 183 | my $merger = merger($self, $spec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 183 | for my $source_spec (sources($self, $spec, $args)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 734 | ▶ | my ($src, $src_cnf) = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'ARRAY' eq ref $source_spec | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ? $source_spec->@* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | : ($source_spec, {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 734 | $src = $self->{factory}->($src, 'collect'); # "resolve" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 734 | $src_cnf = {$spec->%*, $src_cnf->%*, config => $config}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 734 | my ($slice, $residual_args) = $src->($self, $src_cnf, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 734 | ▶ | push @residual_args, $residual_args->@* if defined $residual_args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 734 | push @sequence, $slice; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 734 | $config = $merger->(@sequence); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } ## end for my $source_spec (sources...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 183 | return ($config, \@residual_args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } ## end sub collect | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 184 | ▶ | sub collect_options ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect_options: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 184 | my $factory = $self->{factory}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | my $collect = $spec->{collect} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 184 | ▶ | // $self->{application}{configuration}{collect} // \&collect; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
($spec->{"collect"} // $self->{"application"}{"configuration"}{"collect"}) // \&App::Easer::V1::collect
$spec->{"collect"} // $self->{"application"}{"configuration"}{"collect"}
MC/DC50%1/2
($spec->{"collect"} // $self->{"application"}{"configuration"}{"collect"}) // \&App::Easer::V1::collect
$spec->{"collect"}
$self->{"application"}{"configuration"}{"collect"}
Truth table66%2/3
A // B
A= $spec->{"collect"}B= $self->{"application"}{"configuration"}{"collect"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 184 | my $collector = $factory->($collect, 'collect'); # "resolve" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 184 | (my $config, $args) = $collector->($self, $spec, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 184 | push $self->{configs}->@*, $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 184 | return $args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } ## end sub collect_options | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 25 | ▶ | sub commandline_help ($getopt) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commandline_help: called CC=24 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 25 | my @retval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 25 | my ($mode, $type, $desttype, $min, $max, $default); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 25 | ▶ | if (substr($getopt, -1, 1) eq '!') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 10 | $type = 'bool'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 10 | substr $getopt, -1, 1, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 10 | push @retval, 'boolean option'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | elsif (substr($getopt, -1, 1) eq '+') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $mode = 'increment'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | substr $getopt, -1, 1, ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | push @retval, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 'incremental option (adds 1 every time it is provided)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } ## end elsif (substr($getopt, -1...)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | elsif ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | $getopt =~ s<( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | [:=]) # 1 mode | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ([siof]) # 2 type | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ([@%])? # 3 desttype | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | \{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | (\d*)? # 4 min | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ,? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | (\d*)? # 5 max | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | \} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | )? \z><>mxs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 15 | ▶ | $mode = $1 eq '=' ? 'mandatory' : 'optional'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 15 | $type = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 15 | $desttype = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 15 | $min = $4; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 15 | $max = $5; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 15 | ▶ | if (defined $min) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $mode = $min ? 'optional' : 'required'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $type = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | s => 'string', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | i => 'integer', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | o => 'perl-extended-integer', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | f => 'float', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 15 | }->{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 15 | my $line = "$mode $type option"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 15 | ▶ | $line .= ", at least $min times" if defined($min) && $min > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $min and $min > 1
MC/DC0%0/2
defined $min and $min > 1
defined $min
$min > 1
Truth table33%1/3
A and B
A= defined $minB= $min > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 15 | ▶ | $line .= ", no more than $max times" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $max and length $max
MC/DC0%0/2
defined $max and length $max
defined $max
length $max
Truth table33%1/3
A and B
A= defined $maxB= length $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | if defined($max) && length($max); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 15 | ▶ | $line .= ", list valued" if defined($desttype) && $desttype eq '@'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $desttype and $desttype eq "\@"
MC/DC0%0/2
defined $desttype and $desttype eq "\@"
defined $desttype
$desttype eq "\@"
Truth table33%1/3
A and B
A= defined $desttypeB= $desttype eq "\@"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 15 | push @retval, $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } ## end elsif ($getopt =~ s<( )? \z><>mxs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | elsif ($getopt =~ s<: (\d+) ([@%])? \z><>mxs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $mode = 'optional'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $type = 'i'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $default = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $desttype = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $line = "optional integer, defaults to $default"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $line .= ", list valued" if defined($desttype) && $desttype eq '@'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $desttype and $desttype eq "\@"
MC/DC0%0/2
defined $desttype and $desttype eq "\@"
defined $desttype
$desttype eq "\@"
Truth table0%0/3
A and B
A= defined $desttypeB= $desttype eq "\@"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | push @retval, $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } ## end elsif ($getopt =~ s<: (\d+) ([@%])? \z><>mxs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | elsif ($getopt =~ s<:+ ([@%])? \z><>mxs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $mode = 'optional'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $type = 'i'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $default = 'increment'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $desttype = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $line = "optional integer, current value incremented if omitted"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $line .= ", list valued" if defined($desttype) && $desttype eq '@'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $desttype and $desttype eq "\@"
MC/DC0%0/2
defined $desttype and $desttype eq "\@"
defined $desttype
$desttype eq "\@"
Truth table0%0/3
A and B
A= defined $desttypeB= $desttype eq "\@"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | push @retval, $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } ## end elsif ($getopt =~ s<:+ ([@%])? \z><>mxs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 25 | my @alternatives = split /\|/, $getopt; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 25 | ▶ | if ($type eq 'bool') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | push @retval, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 10 | ▶ | if (length($_) == 1) { "-$_" } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 10 | else { "--$_ | --no-$_" } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } @alternatives; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } ## end if ($type eq 'bool') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | elsif ($mode eq 'optional') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | push @retval, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if (length($_) == 1) { "-$_ [<value>]" } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | else { "--$_ [<value>]" } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } @alternatives; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } ## end elsif ($mode eq 'optional') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | push @retval, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 15 | ▶ | if (length($_) == 1) { "-$_ <value>" } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 15 | else { "--$_ <value>" } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } @alternatives; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } ## end else [ if ($type eq 'bool') ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 25 | return @retval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } ## end sub commandline_help ($getopt) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 184 | ▶ | sub commit_configuration ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commit_configuration: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 184 | ▶ | my $commit = $spec->{commit} // return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$spec->{"commit"} // (return)
MC/DC0%0/1
$spec->{"commit"} // (return)
$spec->{"commit"}
Truth table50%1/2
A
A= $spec->{"commit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->{factory}->($commit, 'commit')->($self, $spec, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub d (@stuff) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
d: not called CC=2 SCAR=10.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 22 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | local $Data::Dumper::Indent = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | warn Data::Dumper::Dumper(@stuff % 2 ? \@stuff : {@stuff}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } ## end sub d (@stuff) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 183 | ▶ | sub default_getopt_config ($self, $spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_getopt_config: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 183 | my @r = qw< gnu_getopt >; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 183 | ▶ | push @r, qw< require_order pass_through > | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | if has_children($self, $spec); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 183 | ▶ | push @r, qw< pass_through > if $spec->{'allow-residual-options'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 183 | return \@r; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 93 | ▶ | sub execute ($self, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 93 | my $command = $self->{trail}[-1][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | my $executable = fetch_spec_for($self, $command)->{execute} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 93 | ▶ | or die "no executable for '$command'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 93 | $executable = $self->{factory}->($executable, 'execute'); # "resolve" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 93 | ▶ | my $config = $self->{configs}[-1] // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"configs"}[-1] // {}
MC/DC0%0/1
$self->{"configs"}[-1] // {}
$self->{"configs"}[-1]
Truth table50%1/2
A
A= $self->{"configs"}[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 93 | return $executable->($self, $config, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } ## end sub execute | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 37 | ▶ | sub fetch_subcommand_default ($self, $spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_subcommand_default: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 37 | my $acfg = $self->{application}{configuration}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | my $child = exists($spec->{'default-child'}) ? $spec->{'default-child'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 37 | ▶ | : exists($acfg->{'default-child'}) ? $acfg->{'default-child'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | : get_child($self, $spec, 'help'); # help is last resort | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 37 | ▶ | return ($child, $child) if defined $child && length $child; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $child and length $child
MC/DC100%2/2
defined $child and length $child
defined $child
length $child
Truth table100%3/3
A and B
A= defined $childB= length $child
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 184 | ▶ | sub fetch_subcommand ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_subcommand: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 184 | ▶ | my ($subc, $alias) = fetch_subcommand_wh($self, $spec, $args) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 85 | my $r = ref $subc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 85 | ▶ | if ($r eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | $subc = $spec->{children}[$subc->{index}] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | ▶ | if scalar(keys $subc->%*) == 1 && defined $subc->{index}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar keys %$subc == 1 and defined $subc->{"index"}
MC/DC50%1/2
scalar keys %$subc == 1 and defined $subc->{"index"}
scalar keys %$subc == 1
defined $subc->{"index"}
Truth table66%2/3
A and B
A= scalar keys %$subc == 1B= defined $subc->{"index"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | $r = ref $subc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | ▶ | return ($subc, $subc->{supports}[0]) if $r eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | $alias = $subc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 83 | ▶ | die "invalid sub-command (ref to $r)" if $r; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 83 | return ($subc, $alias); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 184 | ▶ | sub fetch_subcommand_wh ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_subcommand_wh: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # if there's a dispatch, use that to figure out where to go next | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # **this** might even overcome having children at all! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 184 | for my $cfg ($spec, $self->{application}{configuration}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 366 | ▶ | next unless exists $cfg->{dispatch}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | my $sub = $self->{factory}->($cfg->{dispatch}, 'dispatch'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | ▶ | defined(my $child = $sub->($self, $spec, $args)) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | return ($child, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # regular course here, no point in going forth without children | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 182 | ▶ | return unless has_children($self, $spec); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # use defaults if there's no argument to investigate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 112 | ▶ | return fetch_subcommand_default($self, $spec) unless $args->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # try to get a child from the first argument | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 77 | ▶ | if (my $child = get_child($self, $spec, $args->[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 65 | return ($child, shift $args->@*); # consumed arg name | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # the first argument didn't help, but we might want to fallback | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 12 | for my $cfg ($spec, $self->{application}{configuration}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 18 | ▶ | if (exists $cfg->{fallback}) { # executable | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | defined(my $fb = $cfg->{fallback}) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | my $sub = $self->{factory}->($fb, 'fallback'); # "resolve" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | defined(my $child = $sub->($self, $spec, $args)) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | return ($child, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 16 | ▶ | if (exists $spec->{'fallback-to'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | defined(my $fbto = $spec->{'fallback-to'}) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | return ($fbto, $fbto); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | return fetch_subcommand_default($self, $spec) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 14 | ▶ | if $cfg->{'fallback-to-default'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # no fallback at this point... it's an error, build a message and die! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 6 | my @names = map { $_->[1] } $self->{trail}->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | shift @names; # remove first one | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 6 | my $path = join '/', @names, $args->[0]; # $args->[0] was the candidate | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 6 | die "cannot find sub-command '$path'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } ## end sub fetch_subcommand_wh | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 104 | ▶ | sub generate_factory ($c) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_factory: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 104 | my $w = \&stock_factory; # default factory | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 104 | ▶ | $w = stock_factory($c->{create}, 'factory', $c) if defined $c->{create}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 104 | ▶ | return sub ($e, $d = '') { $w->($e, $d, $c) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 88 | ▶ | sub get_child ($self, $spec, $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_child: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 88 | for my $child (get_children($self, $spec)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 157 | my $command = fetch_spec_for($self, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 199 | ▶ | unless grep { $_ eq $name } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$command->{"supports"} //= [$child]
MC/DC100%1/1
$command->{"supports"} //= [$child]
$command->{"supports"}
Truth table100%2/2
A
A= $command->{"supports"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 157 | ▶ | ($command->{supports} //= [$child])->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 76 | return $child; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } ## end for my $child (get_children...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } ## end sub get_child | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 10 | ▶ | sub stock_ChildrenByPrefix ($self, $spec, @prefixes) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_ChildrenByPrefix: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 10 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | my @expanded_inc = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 10 | my ($v, $dirs) = File::Spec->splitpath($_, 'no-file'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 70 | [$v, File::Spec->splitdir($dirs)]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } @INC; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 10 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 10 | my @parts = split m{::}mxs, $_ . 'x'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 10 | substr(my $bprefix = pop @parts, -1, 1, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 10 | my ($v, @dirs) = $_->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 70 | my $dirs = File::Spec->catdir(@dirs, @parts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 70 | ▶ | if (opendir my $dh, File::Spec->catpath($v, $dirs, '')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 18 | grep { ! $seen{$_}++ } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 18 | substr(my $lastpart = $_, -3, 3, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 18 | join '::', @parts, $lastpart; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 10 | my $path = File::Spec->catpath($v, $dirs, $_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 46 | ▶ | (-e $path && ! -d $path) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
-e $path && !(-d $path) && substr($_, 0, length $bprefix) eq $bprefix && substr($_, -3, 3) eq '.pm'
-e $path and not -d $path and substr($_, 0, length $bprefix) eq $bprefix
-e $path and not -d $path
MC/DC25%1/4
-e $path && !(-d $path) && substr($_, 0, length $bprefix) eq $bprefix && substr($_, -3, 3) eq '.pm'
-e $path
not -d $path
substr($_, 0, length $bprefix) eq $bprefix
substr($_, -3, 3) eq '.pm'
Truth table40%2/5
A and not(B) and C && D
A= -e $pathB= not -d $pathC= substr($_, 0, length $bprefix) eq $bprefixD= substr($_, -3, 3) eq '.pm'
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | && substr($_, 0, length($bprefix)) eq $bprefix | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | && substr($_, -3, 3) eq '.pm' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } readdir $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 60 | else { () } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } @expanded_inc; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } @prefixes; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 126 | ▶ | sub expand_children ($self, $spec, $child_spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_children: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 126 | ▶ | return $child_spec unless ref($child_spec) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 10 | my ($exe, @args) = $child_spec->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 10 | return $self->{factory}->($exe, 'children')->($self, $spec, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 482 | ▶ | sub get_children ($self, $spec, $expand = 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_children: called CC=15 SCAR=31.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 482 | ▶ | return if $spec->{leaf}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 411 | ▶ | return if exists($spec->{children}) && !$spec->{children}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $spec->{"children"} and not $spec->{"children"}
MC/DC100%2/2
exists $spec->{"children"} and not $spec->{"children"}
exists $spec->{"children"}
not $spec->{"children"}
Truth table100%3/3
A and not(B)
A= exists $spec->{"children"}B= not $spec->{"children"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 388 | ▶ | my @children = ($spec->{children} // [])->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$spec->{"children"} // []
MC/DC100%1/1
$spec->{"children"} // []
$spec->{"children"}
Truth table100%2/2
A
A= $spec->{"children"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # set auto-leaves as 1 by default, new in 0.007002 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | $self->{application}{configuration}{'auto-leaves'} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 388 | ▶ | unless exists $self->{application}{configuration}{'auto-leaves'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 388 | ▶ | if $self->{application}{configuration}{'auto-leaves'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"application"}{"configuration"}{"auto-leaves"} and @children == 0
MC/DC100%2/2
$self->{"application"}{"configuration"}{"auto-leaves"} and @children == 0
$self->{"application"}{"configuration"}{"auto-leaves"}
@children == 0
Truth table100%3/3
A and B
A= $self->{"application"}{"configuration"}{"auto-leaves"}B= @children == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | && @children == 0; # no auto-children for leaves under auto-leaves | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # skip expansion if $expand is false (default is expand) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 333 | ▶ | @children = map { expand_children($self, $spec, $_) } @children | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | if $expand; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | my @auto = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | exists $self->{application}{configuration}{'auto-children'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 333 | ▶ | ? (($self->{application}{configuration}{'auto-children'} // [])->@*) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"application"}{"configuration"}{"auto-children"} // []
MC/DC0%0/1
$self->{"application"}{"configuration"}{"auto-children"} // []
$self->{"application"}{"configuration"}{"auto-children"}
Truth table0%0/2
A
A= $self->{"application"}{"configuration"}{"auto-children"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | : (qw< help commands >); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 333 | ▶ | if (exists $spec->{'no-auto'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if (ref $spec->{'no-auto'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my %no = map { $_ => 1 } $spec->{'no-auto'}->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | @auto = grep { !$no{$_} } @auto; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | elsif ($spec->{'no-auto'} eq '*') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | @auto = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | die "invalid no-auto, array or '*' are allowed\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } ## end if (exists $spec->{'no-auto'...}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 333 | return (@children, @auto); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } ## end sub get_children | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # traverse a whole @$list of sub-commands from $start. This is used to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # list "commands" at a certain sub-level or show help | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 27 | ▶ | sub get_descendant ($self, $start, $list) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_descendant: called CC=6 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 27 | my $target = $start; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 27 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 27 | for my $desc ($list->@*) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 11 | ▶ | $path = defined($path) ? "$path/$desc" : $desc; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 11 | ▶ | my $command = fetch_spec_for($self, $target) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | or die "cannot find sub-command '$path'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 11 | ▶ | defined($target = get_child($self, $command, $desc)) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | or die "cannot find sub-command '$path'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } ## end for my $desc ($list->@*) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # check that this last is associated to a real command | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 27 | ▶ | return $target if fetch_spec_for($self, $target); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | die "cannot find sub-command '$path'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } ## end sub get_descendant | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 365 | ▶ | sub has_children ($self, $spec) { get_children($self, $spec, 0) ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_children: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 737 | ▶ | sub hash_merge { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hash_merge: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 737 | my (%retval, %is_overridable); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 737 | for my $href (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1850 | for my $src_key (keys $href->%*) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 638 | my $dst_key = $src_key; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 638 | my $this_overridable; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 638 | ▶ | if ($dst_key =~ m{\A //= (.*) \z}mxs) { # overridable | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 354 | $dst_key = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 354 | ▶ | $is_overridable{$dst_key} = 1 unless exists $retval{$dst_key}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 354 | $this_overridable = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | $retval{$dst_key} = $href->{$src_key} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 638 | ▶ | if $is_overridable{$dst_key} || ! exists($retval{$dst_key}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$is_overridable{$dst_key} or not exists $retval{$dst_key}
MC/DC100%2/2
$is_overridable{$dst_key} or not exists $retval{$dst_key}
$is_overridable{$dst_key}
not exists $retval{$dst_key}
Truth table100%3/3
A or not(B)
A= $is_overridable{$dst_key}B= not exists $retval{$dst_key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 638 | ▶ | $is_overridable{$dst_key} = 0 unless $this_overridable; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 737 | return \%retval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # was a simple: return {map { $_->%* } reverse @_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 19 | ▶ | sub list_commands ($self, $children) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_commands: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 19 | my $retval = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 19 | open my $fh, '>', \$retval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 19 | for my $child ($children->@*) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 49 | my $command = fetch_spec_for($self, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 49 | my $help = $command->{help}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 49 | ▶ | my @aliases = ($command->{supports} // [$child])->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$command->{"supports"} // [$child]
MC/DC0%0/1
$command->{"supports"} // [$child]
$command->{"supports"}
Truth table50%1/2
A
A= $command->{"supports"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 49 | ▶ | next unless @aliases; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 49 | printf {$fh} "%15s: %s\n", shift(@aliases), $help; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 49 | ▶ | printf {$fh} "%15s (also as: %s)\n", '', join ', ', @aliases | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | if @aliases; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } ## end for my $child ($children...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 19 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 19 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } ## end sub list_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 109 | ▶ | sub load_application ($application) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_application: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 109 | ▶ | return $application if 'HASH' eq ref $application; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 5 | my $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 5 | ▶ | if ('SCALAR' eq ref $application) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | $text = $$application; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | my $fh = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 'GLOB' eq ref $application | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ? $application | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | ▶ | : do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | ▶ | open my $fh, '<:encoding(UTF-8)', $application | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | or die "cannot open '$application'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 2 | $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | local $/; # slurp mode | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | $text = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } ## end else [ if ('SCALAR' eq ref $application)] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | return eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 5 | require JSON::PP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 5 | JSON::PP::decode_json($text); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 5 | ▶ | } // eval { eval $text; } // die "cannot load application\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
(eval {
do {
require JSON::PP;
JSON::PP::decode_json($text)
}
} // eval {
do {
eval $text
}
}) // die("cannot load application\n")
eval {
do {
require JSON::PP;
JSON::PP::decode_json($text)
}
} // eval {
do {
eval $text
}
}
MC/DC0%0/2
(eval {
do {
require JSON::PP;
JSON::PP::decode_json($text)
}
} // eval {
do {
eval $text
}
}) // die("cannot load application\n")
eval {
do {
require JSON::PP;
JSON::PP::decode_json($text)
}
}
eval {
do {
eval $text
}
}
Truth table66%2/3
A // B
A= eval {
do {
require JSON::PP;
JSON::PP::decode_json($text)
}
}B= eval {
do {
eval $text
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } ## end sub load_application ($application) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 186 | ▶ | sub merger ($self, $spec = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merger: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | my $merger = $spec->{merge} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 186 | ▶ | // $self->{application}{configuration}{merge} // \&hash_merge; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($spec->{"merge"} // $self->{"application"}{"configuration"}{"merge"}) // \&App::Easer::V1::hash_merge
$spec->{"merge"} // $self->{"application"}{"configuration"}{"merge"}
MC/DC0%0/2
($spec->{"merge"} // $self->{"application"}{"configuration"}{"merge"}) // \&App::Easer::V1::hash_merge
$spec->{"merge"}
$self->{"application"}{"configuration"}{"merge"}
Truth table33%1/3
A // B
A= $spec->{"merge"}B= $self->{"application"}{"configuration"}{"merge"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 186 | return $self->{factory}->($merger, 'merge'); # "resolve" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 204 | ▶ | sub env_namer ($self, $cspec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
env_namer: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | my $namenv = $cspec->{namenv} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 204 | ▶ | // $self->{application}{configuration}{namenv} // \&stock_NamEnv; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($cspec->{"namenv"} // $self->{"application"}{"configuration"}{"namenv"}) // \&App::Easer::V1::stock_NamEnv
$cspec->{"namenv"} // $self->{"application"}{"configuration"}{"namenv"}
MC/DC0%0/2
($cspec->{"namenv"} // $self->{"application"}{"configuration"}{"namenv"}) // \&App::Easer::V1::stock_NamEnv
$cspec->{"namenv"}
$self->{"application"}{"configuration"}{"namenv"}
Truth table33%1/3
A // B
A= $cspec->{"namenv"}B= $self->{"application"}{"configuration"}{"namenv"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 204 | $namenv = $self->{factory}->($namenv, 'namenv'); # "resolve" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 204 | ▶ | return sub ($ospec) { $namenv->($self, $cspec, $ospec) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } ## end sub name_for_option ($o) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 182 | ▶ | sub name_for_option ($o) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name_for_option: called CC=6 SCAR=28.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 182 | ▶ | return $o->{name} if defined $o->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 182 | ▶ | return $1 if defined $o->{getopt} && $o->{getopt} =~ m{\A(\w+)}mxs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $o->{"getopt"} and $o->{"getopt"} =~ /\A(\w+)/msux
MC/DC0%0/2
defined $o->{"getopt"} and $o->{"getopt"} =~ /\A(\w+)/msux
defined $o->{"getopt"}
$o->{"getopt"} =~ /\A(\w+)/msux
Truth table33%1/3
A and B
A= defined $o->{"getopt"}B= $o->{"getopt"} =~ /\A(\w+)/msux
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | return lc $o->{environment} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if defined $o->{environment} && $o->{environment} ne '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $o->{"environment"} and $o->{"environment"} ne 1
MC/DC0%0/2
defined $o->{"environment"} and $o->{"environment"} ne 1
defined $o->{"environment"}
$o->{"environment"} ne 1
Truth table0%0/3
A and B
A= defined $o->{"environment"}B= $o->{"environment"} ne 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | return '~~~'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } ## end sub name_for_option ($o) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 184 | ▶ | sub params_validate ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
params_validate: called CC=3 SCAR=16.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | my $validator = $spec->{validate} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 184 | ▶ | // $self->{application}{configuration}{validate} // return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($spec->{"validate"} // $self->{"application"}{"configuration"}{"validate"}) // (return)
$spec->{"validate"} // $self->{"application"}{"configuration"}{"validate"}
MC/DC0%0/2
($spec->{"validate"} // $self->{"application"}{"configuration"}{"validate"}) // (return)
$spec->{"validate"}
$self->{"application"}{"configuration"}{"validate"}
Truth table33%1/3
A // B
A= $spec->{"validate"}B= $self->{"application"}{"configuration"}{"validate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | require Params::Validate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | Params::Validate::validate($self->{configs}[-1]->%*, $validator); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } ## end sub params_validate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 8 | ▶ | sub print_commands ($self, $target) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_commands: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 8 | my $command = fetch_spec_for($self, $target); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | my $fh = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 8 | ▶ | $self->{application}{configuration}{'help-on-stderr'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ? \*STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | : \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 8 | ▶ | if (my @children = get_children($self, $command)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 7 | print {$fh} list_commands($self, \@children); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 1 | print {$fh} "no sub-commands\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 21 | ▶ | sub print_help ($self, $target) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_help: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 21 | my $command = fetch_spec_for($self, $target); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 21 | my $enamr = env_namer($self, $command); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | my $fh = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 21 | ▶ | $self->{application}{configuration}{'help-on-stderr'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | ? \*STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | : \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 21 | print {$fh} $command->{help}, "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 21 | ▶ | if (defined(my $description = $command->{description})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 20 | $description =~ s{\A\s+|\s+\z}{}gmxs; # trim | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 20 | $description =~ s{^}{ }gmxs; # add some indentation | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 20 | print {$fh} "Description:\n$description\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 13 | printf {$fh} "Can be called as: %s\n\n", join ', ', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | $command->{supports}->@* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 21 | ▶ | if $command->{supports}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 21 | ▶ | my $options = $command->{options} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$command->{"options"} // []
MC/DC100%1/1
$command->{"options"} // []
$command->{"options"}
Truth table100%2/2
A
A= $command->{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 21 | ▶ | if ($options->@*) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 15 | print {$fh} "Options:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 15 | my $n = 0; # count the option | |||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 15 | for my $option ($options->@*) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 25 | ▶ | print {$fh} "\n" if $n++; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 25 | ▶ | printf {$fh} "%15s: %s\n", name_for_option($option), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$option->{"help"} // ""
MC/DC0%0/1
$option->{"help"} // ""
$option->{"help"}
Truth table50%1/2
A
A= $option->{"help"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 25 | $option->{help} // ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 25 | ▶ | if (exists $option->{getopt}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 25 | my @lines = commandline_help($option->{getopt}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 25 | printf {$fh} "%15s command-line: %s\n", '', shift(@lines); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 25 | printf {$fh} "%15s %s\n", '', $_ for @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 25 | ▶ | if (defined(my $env_name = $enamr->($option))) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 16 | printf {$fh} "%15s environment : %s\n", '', $env_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 8 | ▶ | printf {$fh} "%15s default : %s\n", '', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$option->{"default"} // "*undef*"
MC/DC0%0/1
$option->{"default"} // "*undef*"
$option->{"default"}
Truth table50%1/2
A
A= $option->{"default"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | $option->{default} // '*undef*' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 25 | ▶ | if exists $option->{default}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } ## end for my $option ($options...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 15 | print {$fh} "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } ## end if ($options->@*) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 6 | print {$fh} "This command has no options.\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 21 | ▶ | if (my @children = get_children($self, $command)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 12 | print {$fh} "Sub commands:\n", list_commands($self, \@children), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 9 | print {$fh} "no sub-commands\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 403 | ▶ | sub stock_SpecFromHash ($s, $cmd) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_SpecFromHash: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 403 | ▶ | return $cmd if ref($cmd) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 390 | ▶ | return $s->{application}{commands}{$cmd} // undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$s->{"application"}{"commands"}{$cmd} // undef
MC/DC100%1/1
$s->{"application"}{"commands"}{$cmd} // undef
$s->{"application"}{"commands"}{$cmd}
Truth table100%2/2
A
A= $s->{"application"}{"commands"}{$cmd}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 151 | ▶ | sub stock_SpecFromHashOrModule ($s, $cmd) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_SpecFromHashOrModule: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 151 | ▶ | return $cmd if ref($cmd) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | return $s->{application}{commands}{$cmd} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 151 | ▶ | //= $s->{factory}->($cmd, 'spec')->(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$s->{"application"}{"commands"}{$cmd} //= $s->{"factory"}->($cmd, "spec")->()
MC/DC0%0/2
$s->{"application"}{"commands"}{$cmd} //= $s->{"factory"}->($cmd, "spec")->()
$s->{"application"}{"commands"}{$cmd}
$s->{"factory"}->($cmd, "spec")->()
Truth table66%2/3
A //= B
A= $s->{"application"}{"commands"}{$cmd}B= $s->{"factory"}->($cmd, "spec")->()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 554 | ▶ | sub fetch_spec_for ($self, $command) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_spec_for: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | my $fetcher = $self->{application}{configuration}{specfetch} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 554 | ▶ | // \&stock_SpecFromHash; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"application"}{"configuration"}{"specfetch"} // \&App::Easer::V1::stock_SpecFromHash
MC/DC100%1/1
$self->{"application"}{"configuration"}{"specfetch"} // \&App::Easer::V1::stock_SpecFromHash
$self->{"application"}{"configuration"}{"specfetch"}
Truth table100%2/2
A
A= $self->{"application"}{"configuration"}{"specfetch"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 554 | return $self->{factory}->($fetcher, 'specfetch')->($self, $command); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 103 | ▶ | sub run ($application, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 103 | $application = add_auto_commands(load_application($application)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | application => $application, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | configs => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | factory => generate_factory($application->{factory} // {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | helpers => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 'print-commands' => \&print_commands, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 'print-help' => \&print_help, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 103 | ▶ | trail => [['MAIN', $application->{commands}{MAIN}{name}]], | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$application->{"factory"} // {}
MC/DC0%0/1
$application->{"factory"} // {}
$application->{"factory"}
Truth table50%1/2
A
A= $application->{"factory"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 103 | while ('necessary') { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 188 | my $command = $self->{trail}[-1][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 188 | ▶ | my $spec = fetch_spec_for($self, $command) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | or die "no definition for '$command'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 184 | $args = collect_options($self, $spec, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 184 | validate_configuration($self, $spec, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 184 | commit_configuration($self, $spec, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 184 | ▶ | my ($subc, $alias) = fetch_subcommand($self, $spec, $args) or last; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 85 | push $self->{trail}->@*, [$subc, $alias]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } ## end while ('necessary') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 93 | ▶ | return execute($self, $args) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
execute($self, $args) // 0
MC/DC0%0/1
execute($self, $args) // 0
execute($self, $args)
Truth table50%1/2
A
A= execute($self, $args)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } ## end sub run | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 2 | ▶ | sub slurp ($file, $mode = '<:encoding(UTF-8)') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slurp: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 2 | ▶ | open my $fh, $mode, $file or die "open('$file'): $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 2 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 2 | return <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 183 | ▶ | sub sources ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sources: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | my $s = $spec->{sources} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | // $self->{application}{configuration}{sources} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 183 | ▶ | // \&stock_DefaultSources; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
($spec->{"sources"} // $self->{"application"}{"configuration"}{"sources"}) // \&App::Easer::V1::stock_DefaultSources
$spec->{"sources"} // $self->{"application"}{"configuration"}{"sources"}
MC/DC100%2/2
($spec->{"sources"} // $self->{"application"}{"configuration"}{"sources"}) // \&App::Easer::V1::stock_DefaultSources
$spec->{"sources"}
$self->{"application"}{"configuration"}{"sources"}
Truth table100%3/3
A // B
A= $spec->{"sources"}B= $self->{"application"}{"configuration"}{"sources"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 183 | ▶ | $s = $self->{factory}->($s, 'sources')->() if 'ARRAY' ne ref $s; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 183 | return $s->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } ## end sub sources | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 183 | ▶ | sub stock_CmdLine ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_CmdLine: called CC=8 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 183 | my @args = $args->@*; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 183 | ▶ | my $goc = $spec->{'getopt-config'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$spec->{"getopt-config"} // default_getopt_config($self, $spec)
MC/DC0%0/2
$spec->{"getopt-config"} // default_getopt_config($self, $spec)
$spec->{"getopt-config"}
default_getopt_config($self, $spec)
Truth table33%1/3
A // B
A= $spec->{"getopt-config"}B= default_getopt_config($self, $spec)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | // default_getopt_config($self, $spec); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 183 | require Getopt::Long; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 183 | Getopt::Long::Configure('default', $goc->@*); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 183 | my %option_for; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | my @specs = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 238 | my $go = $_->{getopt}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | ref($go) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | ? ($go->[0] => sub { $go->[1]->(\%option_for, @_) }) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 238 | ▶ | : $go; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 183 | ▶ | grep { exists $_->{getopt} } ($spec->{options} // [])->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$spec->{"options"} // []
MC/DC100%1/1
$spec->{"options"} // []
$spec->{"options"}
Truth table100%2/2
A
A= $spec->{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 183 | ▶ | Getopt::Long::GetOptionsFromArray(\@args, \%option_for, @specs) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | or die "bailing out\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # Check if we want to forbid the residual @args to start with a '-' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 183 | my $strict = !$spec->{'allow-residual-options'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 183 | ▶ | if ($strict && @args && $args[0] =~ m{\A -}mxs) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$strict and @args and $args[0] =~ /\A -/msux
$strict and @args
MC/DC0%0/3
$strict and @args and $args[0] =~ /\A -/msux
$strict
@args
$args[0] =~ /\A -/msux
Truth table50%2/4
A and B and C
A= $strictB= @argsC= $args[0] =~ /\A -/msux
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | Getopt::Long::Configure('default', 'gnu_getopt'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | Getopt::Long::GetOptionsFromArray(\@args, {}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | die "bailing out\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 183 | return (\%option_for, \@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } ## end sub stock_CmdLine | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 3 | ▶ | sub stock_JsonFileFromConfig ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_JsonFileFromConfig: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 3 | ▶ | my $key = $spec->{'config-option'} // 'config'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$spec->{"config-option"} // "config"
MC/DC0%0/1
$spec->{"config-option"} // "config"
$spec->{"config-option"}
Truth table50%1/2
A
A= $spec->{"config-option"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 3 | ▶ | return {} if !exists($spec->{config}{$key}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 1 | require JSON::PP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | return JSON::PP::decode_json(slurp($spec->{config}{$key})); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } ## end sub stock_JsonFileFromConfig | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 3 | ▶ | sub stock_JsonFiles ($self, $spec, @ignore) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_JsonFiles: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | return merger($self, $spec)->( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1 | require JSON::PP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | JSON::PP::decode_json(slurp($_)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 3 | ▶ | grep { -e $_ } ($spec->{'config-files'} // [])->@* | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$spec->{"config-files"} // []
MC/DC100%1/1
$spec->{"config-files"} // []
$spec->{"config-files"}
Truth table100%2/2
A
A= $spec->{"config-files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } ## end sub stock_JsonFiles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 181 | ▶ | sub stock_Default ($self, $spec, @ignore) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_Default: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 87 | map { '//=' . name_for_option($_) => $_->{default} } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 181 | ▶ | grep { exists $_->{default} } ($spec->{options} // [])->@* | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$spec->{"options"} // []
MC/DC100%1/1
$spec->{"options"} // []
$spec->{"options"}
Truth table100%2/2
A
A= $spec->{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } ## end sub stock_Default | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 183 | ▶ | sub stock_Environment ($self, $spec, @ignore) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_Environment: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 183 | my $enamr = env_namer($self, $spec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 238 | my $en = $enamr->($_); # name of environment variable | |||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | defined($en) && exists($ENV{$en}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 238 | ▶ | ? (name_for_option($_) => $ENV{$en}) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
defined $en and exists $ENV{$en}
$spec->{"options"} // []
MC/DC100%2/2
defined $en and exists $ENV{$en}
defined $en
exists $ENV{$en}
MC/DC100%1/1
$spec->{"options"} // []
$spec->{"options"}
Truth table100%3/3
A and B
A= defined $enB= exists $ENV{$en}
Truth table100%2/2
A
A= $spec->{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 183 | } ($spec->{options} // [])->@* | |||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } ## end sub stock_Environment | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 263 | ▶ | sub stock_NamEnv ($self, $cspec, $ospec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_NamEnv: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 263 | my $aek = 'auto-environment'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | my $autoenv = exists $cspec->{$aek} ? $cspec->{$aek} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 263 | ▶ | : $self->{application}{configuration}{$aek} // undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{"application"}{"configuration"}{$aek} // undef
MC/DC100%1/1
$self->{"application"}{"configuration"}{$aek} // undef
$self->{"application"}{"configuration"}{$aek}
Truth table100%2/2
A
A= $self->{"application"}{"configuration"}{$aek}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | my $env = exists $ospec->{environment} ? $ospec->{environment} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 263 | ▶ | : $autoenv ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 263 | ▶ | return $env unless ($env // '') eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$env // ""
MC/DC100%1/1
$env // ""
$env
Truth table100%2/2
A
A= $env
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 36 | ▶ | my $appname = $self->{application}{configuration}{name} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"application"}{"configuration"}{"name"} // ""
MC/DC0%0/1
$self->{"application"}{"configuration"}{"name"} // ""
$self->{"application"}{"configuration"}{"name"}
Truth table50%1/2
A
A= $self->{"application"}{"configuration"}{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 36 | my $optname = name_for_option($ospec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 36 | return uc(join '_', $appname, $optname); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 181 | ▶ | sub stock_Parent ($self, $spec, @ignore) { $self->{configs}[-1] // {} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_Parent: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
$self->{"configs"}[-1] // {}
MC/DC100%1/1
$self->{"configs"}[-1] // {}
$self->{"configs"}[-1]
Truth table100%2/2
A
A= $self->{"configs"}[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 7 | ▶ | sub stock_commands ($self, $config, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_commands: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 7 | ▶ | die "this command does not support arguments\n" if $args->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 7 | my $target = get_descendant($self, $self->{trail}[-2][0], $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 7 | print_commands($self, $target); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 7 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } ## end sub stock_commands | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 2166 | ▶ | sub stock_factory ($executable, $default_subname = '', $opts = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_factory: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 90 | ▶ | state $factory = sub ($executable, $default_subname) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | my @prefixes = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | !defined $opts->{prefixes} ? () | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | : 'ARRAY' eq ref $opts->{prefixes} ? ($opts->{prefixes}->@*) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 90 | ▶ | : ($opts->{prefixes}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 90 | push @prefixes, {'+' => 'App::Easer::V1#stock_'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | SEARCH: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 90 | for my $expansion_for (@prefixes) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 96 | for my $p (keys $expansion_for->%*) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 111 | ▶ | next if $p ne substr $executable, 0, length $p; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 74 | substr $executable, 0, length $p, $expansion_for->{$p}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 74 | last SEARCH; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } ## end SEARCH: for my $expansion_for (...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # if it *still* "starts" with '=', it's "inline" Perl code | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 90 | ▶ | return eval $executable if $executable =~ s{\A \s* = \s* }{}mxs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 89 | my ($package, $sname) = split m{\#}mxs, $executable; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 89 | ▶ | $sname = $default_subname unless defined $sname && length $sname; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $sname and length $sname
MC/DC50%1/2
defined $sname and length $sname
defined $sname
length $sname
Truth table66%2/3
A and B
A= defined $snameB= length $sname
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | # first try to see if the sub is already available in $package | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 89 | ▶ | if (my $s = $package->can($sname)) { return $s } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | # otherwise force loading of $package and retry | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 6 | (my $path = "$package.pm") =~ s{::}{/}gmxs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 6 | require $path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 4 | ▶ | if (my $s = $package->can($sname)) { return $s } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | die "no '$sname' in '$package'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 2166 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 2166 | state $cache = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 2166 | my $args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2166 | ▶ | ($executable, $args) = ($executable->{executable}, $executable) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | if 'HASH' eq ref $executable; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 2166 | ▶ | $executable = $cache->{$executable . ' ' . $default_subname} //= | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$cache{$executable . ' ' . $default_subname} //= &$factory($executable, $default_subname)
MC/DC100%2/2
$$cache{$executable . ' ' . $default_subname} //= &$factory($executable, $default_subname)
$$cache{$executable . ' ' . $default_subname}
&$factory($executable, $default_subname)
Truth table100%3/3
A //= B
A= $$cache{$executable . ' ' . $default_subname}B= &$factory($executable, $default_subname)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | $factory->($executable, $default_subname) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | if 'CODE' ne ref $executable; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 2164 | ▶ | return $executable unless $args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | ▶ | return sub { $executable->($args, @_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } ## end sub stock_factory | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 20 | ▶ | sub stock_help ($self, $config, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_help: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 20 | print_help($self, get_descendant($self, $self->{trail}[-2][0], $args)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 20 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } ## end sub stock_help | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 178 | ▶ | sub stock_DefaultSources { [qw< +Default +CmdLine +Environment +Parent >] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_DefaultSources: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 3 | ▶ | sub stock_SourcesWithFiles { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stock_SourcesWithFiles: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 3 | qw< +Default +CmdLine +Environment +Parent | |||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | +JsonFileFromConfig +JsonFiles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | > | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } ## end sub stock_SourcesWithFiles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 184 | ▶ | sub validate_configuration ($self, $spec, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_configuration: called CC=5 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 184 | my $from_spec = $spec->{validate}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 184 | my $from_self = $self->{application}{configuration}{validate}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 184 | my $validator; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 184 | ▶ | if (defined $from_spec && 'HASH' ne ref $from_spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $from_spec and "HASH" ne ref $from_spec
MC/DC0%0/2
defined $from_spec and "HASH" ne ref $from_spec
defined $from_spec
"HASH" ne ref $from_spec
Truth table33%1/3
A and B
A= defined $from_specB= "HASH" ne ref $from_spec
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | $validator = $self->{factory}->($from_spec, 'validate'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | ▶ | elsif (defined $from_self && 'HASH' ne ref $from_self) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $from_self and "HASH" ne ref $from_self
MC/DC0%0/2
defined $from_self and "HASH" ne ref $from_self
defined $from_self
"HASH" ne ref $from_self
Truth table33%1/3
A and B
A= defined $from_selfB= "HASH" ne ref $from_self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $validator = $self->{factory}->($from_self, 'validate'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | else { # use stock one | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 184 | $validator = \¶ms_validate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 184 | $validator->($self, $spec, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } ## end sub validate_configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | exit run( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | $ENV{APPEASER} // { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | commands => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | MAIN => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | name => 'main app', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | help => 'this is the main app', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | description => 'Yes, this really is the main app', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | options => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | name => 'foo', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | description => 'option foo!', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | getopt => 'foo|f=s', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | environment => 'FOO', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | default => 'bar', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | execute => sub ($global, $conf, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my $foo = $conf->{foo}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | say "Hello, $foo!"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 22 | ▶ | 'default-child' => '', # run execute by default | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$ENV{"APPEASER"} // {"commands", {"MAIN", {"name", "main app", "help", "this is the main app", "description", "Yes, this really is the main app", "options", [{"name", "foo", "description", "option foo!", "getopt", "foo|f=s", "environment", "FOO", "default", "bar"}], "execute", sub ($global, $conf, $args) {
my $foo = $conf->{"foo"};
say "Hello, $foo!";
return 0;
}
, "default-child", ""}}}
MC/DC0%0/1
$ENV{"APPEASER"} // {"commands", {"MAIN", {"name", "main app", "help", "this is the main app", "description", "Yes, this really is the main app", "options", [{"name", "foo", "description", "option foo!", "getopt", "foo|f=s", "environment", "FOO", "default", "bar"}], "execute", sub ($global, $conf, $args) {
my $foo = $conf->{"foo"};
say "Hello, $foo!";
return 0;
}
, "default-child", ""}}}
$ENV{"APPEASER"}
Truth table0%0/2
A
A= $ENV{"APPEASER"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | [@ARGV] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | ) unless caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 22 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||