| 1 | package Getopt::Yath::Option::List; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '2.000008'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Getopt::Yath::Util qw/decode_json/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use parent 'Getopt::Yath::Option'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Getopt::Yath::HashBase qw/<split_on/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | sub allows_list { 1 } | ||||||||||||||||||||||||||
|
Subroutine
allows_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 8 | ▶ | sub allows_arg { 1 } | ||||||||||||||||||||||||||
|
Subroutine
allows_arg: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | sub requires_arg { 1 } | ||||||||||||||||||||||||||
|
Subroutine
requires_arg: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | sub allows_default { 1 } | ||||||||||||||||||||||||||
|
Subroutine
allows_default: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub allows_autofill { 0 } | ||||||||||||||||||||||||||
|
Subroutine
allows_autofill: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub requires_autofill { 0 } | ||||||||||||||||||||||||||
|
Subroutine
requires_autofill: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | sub notes { (shift->SUPER::notes(), 'Can be specified multiple times') } | ||||||||||||||||||||||||||
|
Subroutine
notes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 28 | ▶ | sub is_populated { ${$_[1]} && @{${$_[1]}} } | ||||||||||||||||||||||||||
|
Subroutine
is_populated: called CC=2 SCAR=7.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | sub get_clear_value { | ||||||||||||||||||||||||||||
| 24 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_clear_value: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 2 | ▶ | return $self->_get___value(CLEAR(), @_) // []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->_get___value("clear", @_) // []
MC/DC0%0/1
$self->_get___value("clear", @_) // []
$self->_get___value("clear", @_)
Truth table50%1/2
A
A= $self->_get___value("clear", @_)
| |||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub get_initial_value { | ||||||||||||||||||||||||||||
| 29 | 32 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_initial_value: called CC=7 SCAR=22.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 32 | my @val; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 32 | my $env = $self->from_env_vars; | |||||||||||||||||||||||||||
| 34 | 32 | ▶ | for my $name (@{$env || []}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | push @val => $ENV{$name} if defined $ENV{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 32 | ▶ | return \@val if @val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 32 | ▶ | return undef if $self->{+MAYBE}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 32 | ▶ | return $self->_get___value(INITIALIZE()) // []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->_get___value("initialize") // []
MC/DC0%0/1
$self->_get___value("initialize") // []
$self->_get___value("initialize")
Truth table50%1/2
A
A= $self->_get___value("initialize")
| |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub add_value { | ||||||||||||||||||||||||||||
| 45 | 64 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_value: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 64 | my ($ref, @val) = @_; | |||||||||||||||||||||||||||
| 47 | 64 | ▶ | return if $self->maybe && !@val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->maybe and not @val
MC/DC0%0/2
$self->maybe and not @val
$self->maybe
not @val
Truth table33%1/3
A and not(B)
A= $self->maybeB= not @val
| |||||||||||||||||||||||||||||
| 48 | 64 | push @{$$ref} => @val; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | sub normalize_value { | ||||||||||||||||||||||||||||
| 52 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
normalize_value: called CC=4 SCAR=19.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 7 | my (@input) = @_; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 7 | ▶ | if ($input[0] =~ m/^\s*\[.*\]\s*$/s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | my $out; | |||||||||||||||||||||||||||
| 57 | 0 | local $@; | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | unless (eval { local $SIG{__DIE__}; $out = decode_json($input[0]); 1 }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | my ($err) = split /[\n\r]+/, $@; | |||||||||||||||||||||||||||
| 60 | 0 | $err =~ s{at \Q$INC{'Getopt/Yath/Util/JSON.pm'}\E line \d+\..*$}{}; | |||||||||||||||||||||||||||
| 61 | 0 | die "Could not decode JSON string: $err\n====\n$input[0]\n====\n"; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 0 | return @$out; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 7 | my @output; | |||||||||||||||||||||||||||
| 67 | 7 | ▶ | if (my $on = $self->split_on) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 7 | @output = map { $self->SUPER::normalize_value($_) } map { split($on, $_) } @input; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||
| 71 | 0 | @output = map { $self->SUPER::normalize_value($_) } @input; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 7 | return @output; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | ▶ | sub inject_default_long_examples { qq{ '["json","list"]'}, qq{='["json","list"]'} } | ||||||||||||||||||||||||||
|
Subroutine
inject_default_long_examples: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 2 | ▶ | sub inject_default_short_examples { qq{ '["json","list"]'}, qq{='["json","list"]'} } | ||||||||||||||||||||||||||
|
Subroutine
inject_default_short_examples: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | sub default_long_examples { | ||||||||||||||||||||||||||||
| 81 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
default_long_examples: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 4 | my %params = @_; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 4 | my $list = $self->SUPER::default_long_examples(%params); | |||||||||||||||||||||||||||
| 85 | 4 | push @$list => $self->inject_default_long_examples(); | |||||||||||||||||||||||||||
| 86 | 4 | return $list; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub default_short_examples { | ||||||||||||||||||||||||||||
| 90 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
default_short_examples: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 4 | my %params = @_; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 4 | my $list = $self->SUPER::default_long_examples(%params); | |||||||||||||||||||||||||||
| 94 | 4 | push @$list => $self->inject_default_short_examples(); | |||||||||||||||||||||||||||
| 95 | 4 | return $list; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | 1; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | __END__ | ||||||||||||||||||||||||||||