| 1 | 2 | ▶ | use 5.008008; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Zydeco::Lite::App; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Getopt::Kingpin 0.10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Path::Tiny 'path'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Type::Utils 'english_list'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Types::Path::Tiny -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Types::Standard -types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Zydeco::Lite qw( -all !app ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use parent 'Zydeco::Lite'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our @EXPORT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | @Zydeco::Lite::EXPORT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | qw( arg flag command run ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | our @EXPORT_OK = @EXPORT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub make_fake_call ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_fake_call: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | eval "sub { package $pkg; my \$code = shift; &\$code; }"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | our %THIS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | sub app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
app: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | local $THIS{MY_SPEC} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $orig = Zydeco::Lite::_pop_type( CodeRef, @_ ) || sub { 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
&Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_) || sub {
1;
}
MC/DC0%0/2
&Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_) || sub {
1;
}
&Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_)
sub {
1;
}
Truth table33%1/3
A || B
A= &Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_)B= sub {
1;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | my $commands; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | my $wrapped = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=27.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | $orig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | while ( my ( $key, $spec ) = each %{ $Zydeco::Lite::THIS{'APP_SPEC'} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | ▶ | if ( $key =~ /^(class|role):(.+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | if ( $spec->{"-IS_COMMAND"} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ( my $cmdname = lc $2 ) =~ s/::/-/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | push @{ $spec->{with} ||= [] }, '::Zydeco::Lite::App::Trait::Command'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$spec->{"with"} ||= []
MC/DC0%0/1
$spec->{"with"} ||= []
$spec->{"with"}
Truth table50%1/2
A
A= $spec->{"with"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | $spec->{can}{command_name} ||= sub () { $cmdname }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$spec->{"can"}{"command_name"} ||= sub () {
$cmdname;
}
MC/DC0%0/2
$spec->{"can"}{"command_name"} ||= sub () {
$cmdname;
}
$spec->{"can"}{"command_name"}
sub () {
$cmdname;
}
Truth table33%1/3
A ||= B
A= $spec->{"can"}{"command_name"}B= sub () {
$cmdname;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | if ( $spec->{"-IS_COMMAND"} || $spec->{"-FLAGS"} || $spec->{"-ARGS"} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$spec->{"-IS_COMMAND"} or $spec->{"-FLAGS"} or $spec->{"-ARGS"}
$spec->{"-IS_COMMAND"} or $spec->{"-FLAGS"}
MC/DC0%0/3
$spec->{"-IS_COMMAND"} or $spec->{"-FLAGS"} or $spec->{"-ARGS"}
$spec->{"-IS_COMMAND"}
$spec->{"-FLAGS"}
$spec->{"-ARGS"}
Truth table25%1/4
A or B or C
A= $spec->{"-IS_COMMAND"}B= $spec->{"-FLAGS"}C= $spec->{"-ARGS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | my $flags = delete( $spec->{"-FLAGS"} ) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $spec->{'-FLAGS'} || {}
MC/DC0%0/1
delete $spec->{'-FLAGS'} || {}
delete $spec->{'-FLAGS'}
Truth table50%1/2
A
A= delete $spec->{'-FLAGS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | my $args = delete( $spec->{"-ARGS"} ) || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $spec->{'-ARGS'} || []
MC/DC0%0/1
delete $spec->{'-ARGS'} || []
delete $spec->{'-ARGS'}
Truth table50%1/2
A
A= delete $spec->{'-ARGS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | push @{ $spec->{symmethod} ||= [] }, ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$spec->{"symmethod"} ||= []
MC/DC0%0/1
$spec->{"symmethod"} ||= []
$spec->{"symmethod"}
Truth table50%1/2
A
A= $spec->{"symmethod"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | _flags_spec => sub { $flags }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | _args_spec => sub { $args }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | delete $spec->{"-IS_COMMAND"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | delete $spec->{"-FLAGS"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | delete $spec->{"-ARGS"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } #/ if ( $key =~ /^(class|role):(.+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } #/ while ( my ( $key, $spec ...)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | my $spec = $Zydeco::Lite::THIS{'APP_SPEC'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | push @{ $spec->{with} ||= [] }, '::Zydeco::Lite::App::Trait::Application'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$spec->{"with"} ||= []
MC/DC0%0/1
$spec->{"with"} ||= []
$spec->{"with"}
Truth table50%1/2
A
A= $spec->{"with"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | $spec->{can}{'commands'} = sub { @{ $commands or [] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$commands || []
MC/DC0%0/1
$commands || []
$commands
Truth table50%1/2
A
A= $commands
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | ▶ | my $app = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
&make_fake_call(scalar caller)->(\&Zydeco::Lite::app, @_, $wrapped) || $_[0]
MC/DC0%0/2
&make_fake_call(scalar caller)->(\&Zydeco::Lite::app, @_, $wrapped) || $_[0]
&make_fake_call(scalar caller)->(\&Zydeco::Lite::app, @_, $wrapped)
$_[0]
Truth table33%1/3
A || B
A= &make_fake_call(scalar caller)->(\&Zydeco::Lite::app, @_, $wrapped)B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | make_fake_call( caller )->( \&Zydeco::Lite::app, @_, $wrapped ) || $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | $commands = $THIS{MY_SPEC}{"-COMMANDS"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | return $app; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } #/ sub app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | sub flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flag: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | $Zydeco::Lite::THIS{CLASS_SPEC} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | or Zydeco::Lite::confess( "cannot use `flag` outside a role or class" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | my $name = Zydeco::Lite::_shift_type( Str, @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | or Zydeco::Lite::confess( "flags must have a string name" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my %flag_spec = @_ == 1 ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | my $app = $Zydeco::Lite::THIS{APP}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | my $class = $Zydeco::Lite::THIS{CLASS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | $flag_spec{kingpin} ||= sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | __PACKAGE__->_kingpin_handle( $app, $class, flag => $name, \%flag_spec, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$flag_spec{"kingpin"} ||= sub {
__PACKAGE__->_kingpin_handle($app, $class, "flag", $name, \%flag_spec, @_);
}
MC/DC0%0/2
$flag_spec{"kingpin"} ||= sub {
__PACKAGE__->_kingpin_handle($app, $class, "flag", $name, \%flag_spec, @_);
}
$flag_spec{"kingpin"}
sub {
__PACKAGE__->_kingpin_handle($app, $class, "flag", $name, \%flag_spec, @_);
}
Truth table33%1/3
A ||= B
A= $flag_spec{"kingpin"}B= sub {
__PACKAGE__->_kingpin_handle($app, $class, "flag", $name, \%flag_spec, @_);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | $Zydeco::Lite::THIS{CLASS_SPEC}{"-FLAGS"}{$name} = \%flag_spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my %spec = %flag_spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | delete $spec{short}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | delete $spec{env}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | delete $spec{placeholder}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | delete $spec{hidden}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | delete $spec{kingpin}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | delete $spec{kingpin_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | @_ = ( $name, \%spec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | goto \&Zydeco::Lite::has; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } #/ sub flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | sub arg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg: called CC=6 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $Zydeco::Lite::THIS{CLASS_SPEC} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | or Zydeco::Lite::confess( "cannot use `arg` outside a class" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | my $name = Zydeco::Lite::_shift_type( Str, @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | or Zydeco::Lite::confess( "args must have a string name" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my %arg_spec = @_ == 1 ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my $app = $Zydeco::Lite::THIS{APP}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | my $class = $Zydeco::Lite::THIS{CLASS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | $arg_spec{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | $arg_spec{kingpin} ||= sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | __PACKAGE__->_kingpin_handle( $app, $class, arg => $name, \%arg_spec, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$arg_spec{"kingpin"} ||= sub {
__PACKAGE__->_kingpin_handle($app, $class, "arg", $name, \%arg_spec, @_);
}
MC/DC0%0/2
$arg_spec{"kingpin"} ||= sub {
__PACKAGE__->_kingpin_handle($app, $class, "arg", $name, \%arg_spec, @_);
}
$arg_spec{"kingpin"}
sub {
__PACKAGE__->_kingpin_handle($app, $class, "arg", $name, \%arg_spec, @_);
}
Truth table33%1/3
A ||= B
A= $arg_spec{"kingpin"}B= sub {
__PACKAGE__->_kingpin_handle($app, $class, "arg", $name, \%arg_spec, @_);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | push @{ $Zydeco::Lite::THIS{CLASS_SPEC}{"-ARGS"} ||= [] }, \%arg_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"-ARGS"} ||= []
MC/DC0%0/1
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"-ARGS"} ||= []
$Zydeco::Lite::THIS{"CLASS_SPEC"}{"-ARGS"}
Truth table50%1/2
A
A= $Zydeco::Lite::THIS{"CLASS_SPEC"}{"-ARGS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } #/ sub arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | sub _kingpin_handle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_kingpin_handle: called CC=53 SCAR=69.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | my ( $me, $factory, $class, $kind, $name, $spec, $kingpin ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | my $flag = $kingpin->$kind( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $spec->{init_arg} || $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 3 | ▶ | $spec->{documentation} || 'No description available.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$spec->{'init_arg'} || $name
$spec->{'documentation'} || 'No description available.'
MC/DC0%0/2
$spec->{'init_arg'} || $name
$spec->{'init_arg'}
$name
MC/DC0%0/1
$spec->{'documentation'} || 'No description available.'
$spec->{'documentation'}
Truth table33%1/3
A || B
A= $spec->{'init_arg'}B= $name
Truth table50%1/2
A
A= $spec->{'documentation'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | ▶ | if ( not ref $spec->{kingpin_type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | my $reg = 'Type::Registry'->for_class( $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | ▶ | $reg->has_parent or $reg->set_parent( 'Type::Registry'->for_class( $factory ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | my $type = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $spec->{kingpin_type} ? $reg->lookup( $spec->{kingpin_type} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | : ref( $spec->{type} or $spec->{isa} ) ? ( $spec->{type} or $spec->{isa} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | : $spec->{type} ? $reg->lookup( $spec->{type} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | : $spec->{isa} ? $factory->type_library->get_type_for_package( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | $factory->get_class( $spec->{isa} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | : $spec->{does} ? $factory->type_library->get_type_for_package( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | ▶ | $factory->get_role( $spec->{does} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition33%2/6
$spec->{'type'} || $spec->{'isa'}
$spec->{"type"} or $spec->{"isa"}
MC/DC0%0/2
$spec->{'type'} || $spec->{'isa'}
$spec->{'type'}
$spec->{'isa'}
MC/DC0%0/2
$spec->{"type"} or $spec->{"isa"}
$spec->{"type"}
$spec->{"isa"}
Truth table33%1/3
A || B
A= $spec->{'type'}B= $spec->{'isa'}
Truth table33%1/3
A or B
A= $spec->{"type"}B= $spec->{"isa"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | : Str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 3 | $spec->{kingpin_type} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } #/ if ( not ref $spec->{kingpin_type...}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | my $type = $spec->{kingpin_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3 | ▶ | if ( $type <= ArrayRef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ( $type->is_parameterized and $type->parent == ArrayRef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type->is_parameterized and $type->parent == &ArrayRef()
MC/DC0%0/2
$type->is_parameterized and $type->parent == &ArrayRef()
$type->is_parameterized
$type->parent == &ArrayRef()
Truth table0%0/3
A and B
A= $type->is_parameterizedB= $type->parent == &ArrayRef()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $type_parameter = $type->type_parameter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ( $type_parameter <= File ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $flag->existing_file_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | elsif ( $type_parameter <= Dir ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $flag->existing_dir_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | elsif ( $type_parameter <= Path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $flag->file_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | elsif ( $type_parameter <= Int ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $flag->int_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | elsif ( $type_parameter <= Num ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $flag->num_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $flag->string_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } #/ if ( $type->is_parameterized...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $flag->string_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } #/ if ( $type <= ArrayRef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | elsif ( $type <= HashRef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | if ( $type->is_parameterized and $type->parent == ArrayRef ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type->is_parameterized and $type->parent == &ArrayRef()
MC/DC0%0/2
$type->is_parameterized and $type->parent == &ArrayRef()
$type->is_parameterized
$type->parent == &ArrayRef()
Truth table33%1/3
A and B
A= $type->is_parameterizedB= $type->parent == &ArrayRef()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $type_parameter = $type->type_parameter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ( $type_parameter <= File ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $flag->existing_file_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | elsif ( $type_parameter <= Dir ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $flag->existing_dir_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | elsif ( $type_parameter <= Path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $flag->file_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | elsif ( $type_parameter <= Int ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $flag->int_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | elsif ( $type_parameter <= Num ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $flag->num_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $flag->string_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } #/ if ( $type->is_parameterized...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | $flag->string_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | $flag->placeholder( 'KEY=VAL' ) if $flag->can( 'placeholder' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } #/ elsif ( $type <= HashRef ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | elsif ( $type <= Bool ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $flag->bool; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | elsif ( $type <= File ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | $flag->existing_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | elsif ( $type <= Dir ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $flag->existing_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | elsif ( $type <= Path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $flag->file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | elsif ( $type <= Int ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | $flag->int; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | elsif ( $type <= Num ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $flag->num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $flag->string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | if ( $spec->{required} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $flag->required; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | ▶ | if ( $spec->{hidden} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $flag->hidden; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | ▶ | if ( exists $spec->{short} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $flag->short( $spec->{short} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 3 | ▶ | if ( exists $spec->{env} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $flag->override_default_from_envar( $spec->{env} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 3 | ▶ | if ( exists $spec->{placeholder} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $flag->placeholder( $spec->{placeholder} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 3 | ▶ | if ( $kind eq 'arg' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | if ( Types::TypeTiny::CodeLike->check( $spec->{default} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $cr = $spec->{default}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # For flags, MooX::Press does this prefilling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if ( blessed $cr and $cr->isa( 'Ask::Question' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cr->blessed and $cr->isa("Ask::Question")
MC/DC0%0/2
$cr->blessed and $cr->isa("Ask::Question")
$cr->blessed
$cr->isa("Ask::Question")
Truth table0%0/3
A and B
A= $cr->blessedB= $cr->isa("Ask::Question")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $cr->_set_type( $type ) unless $cr->has_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $cr->_set_text( $spec->{documentation} || $name ) unless $cr->has_text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$spec->{'documentation'} || $name
MC/DC0%0/2
$spec->{'documentation'} || $name
$spec->{'documentation'}
$name
Truth table0%0/3
A || B
A= $spec->{'documentation'}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $cr->_set_title( $name ) unless $cr->has_title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $cr->_set_spec( $spec ) unless $cr->has_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | $flag->default( sub { $cr->( $class ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } #/ if ( Types::TypeTiny::CodeLike...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | elsif ( exists $spec->{default} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $flag->default( $spec->{default} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | elsif ( my $builder = $spec->{builder} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | $builder = "_build_$name" if is_Int( $builder ) && $builder eq 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
is_Int($builder) and $builder eq 1
MC/DC0%0/2
is_Int($builder) and $builder eq 1
is_Int($builder)
$builder eq 1
Truth table0%0/3
A and B
A= is_Int($builder)B= $builder eq 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | $flag->default( sub { $class->$builder } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } #/ if ( $kind eq 'arg' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | return $flag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } #/ sub _kingpin_handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | ▶ | sub command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | my $definition = Zydeco::Lite::_pop_type( CodeRef, @_ ) || sub { 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
&Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_) || sub {
1;
}
MC/DC0%0/2
&Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_) || sub {
1;
}
&Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_)
sub {
1;
}
Truth table33%1/3
A || B
A= &Zydeco::Lite::_pop_type(scalar &CodeRef(), \@_)B= sub {
1;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | ▶ | my $name = Zydeco::Lite::_shift_type( Str, @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | or Zydeco::Lite::confess( "commands must have a string name" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | Zydeco::Lite::class( $name, %args, $definition ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | my $class_spec = $Zydeco::Lite::THIS{APP_SPEC}{"class:$name"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | $class_spec->{'-IS_COMMAND'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | ▶ | push @{ $THIS{MY_SPEC}{"-COMMANDS"} ||= [] }, $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Zydeco::Lite::App::THIS{"MY_SPEC"}{"-COMMANDS"} ||= []
MC/DC0%0/1
$Zydeco::Lite::App::THIS{"MY_SPEC"}{"-COMMANDS"} ||= []
$Zydeco::Lite::App::THIS{"MY_SPEC"}{"-COMMANDS"}
Truth table50%1/2
A
A= $Zydeco::Lite::App::THIS{"MY_SPEC"}{"-COMMANDS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } #/ sub command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | ▶ | sub run (&) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 3 | unshift @_, 'execute'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | goto \&Zydeco::Lite::method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | ▶ | Zydeco::Lite::app( 'Zydeco::Lite::App' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | role 'Trait::Application' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | requires qw( commands ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | method '_proto' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 5 | ▶ | my ( $proto ) = ( shift ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_proto: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 5 | ▶ | ref( $proto ) ? $proto : bless( {}, $proto ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | method 'stdio' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | my ( $app, $in, $out, $err ) = ( shift->_proto, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stdio: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $app->{stdin} = $in if $in; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | $app->{stdout} = $out if $out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | $app->{stderr} = $err if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $app; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | method 'config_file' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | method 'find_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | ▶ | my ( $app ) = ( shift->_proto ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | ▶ | my @files = $app->config_file or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | require Perl::OSType; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | my @dirs = ( path( "." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | if ( Perl::OSType::is_os_type( 'Unix' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | ▶ | push @dirs, path( $ENV{XDG_CONFIG_HOME} || '~/.config' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'XDG_CONFIG_HOME'} || '~/.config'
MC/DC0%0/1
$ENV{'XDG_CONFIG_HOME'} || '~/.config'
$ENV{'XDG_CONFIG_HOME'}
Truth table50%1/2
A
A= $ENV{'XDG_CONFIG_HOME'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | push @dirs, path( '/etc' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | elsif ( Perl::OSType::is_os_type( 'Windows' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | push @dirs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | map path( $ENV{$_} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | grep $ENV{$_}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | qw( LOCALAPPDATA APPDATA PROGRAMDATA ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | my @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | for my $dir ( @dirs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | for my $file ( @files ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 3 | my $found = $dir->child( "$file" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | ▶ | push @found, $found if $found->is_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | @found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | method read_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | ▶ | my ( $app ) = ( shift->_proto ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | ▶ | my @files = @_ ? map( path( $_ ), @_ ) : $app->find_config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | my %config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | for my $file ( reverse @files ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | ▶ | next unless $file->is_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | my $this_config = $app->read_single_config($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | ▶ | while ( my ( $section, $sconfig ) = each %$this_config ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | $config{$section} = +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | ▶ | %{ $config{$section} or {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config{$section} || {}
MC/DC0%0/1
$config{$section} || {}
$config{$section}
Truth table50%1/2
A
A= $config{$section}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | ▶ | %{ $sconfig or {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$sconfig || {}
MC/DC0%0/1
$sconfig || {}
$sconfig
Truth table50%1/2
A
A= $sconfig
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } #/ for my $file ( reverse ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | return \%config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | method 'read_single_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | => [ File ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=29.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | ▶ | my ( $app, $file ) = ( shift->_proto, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_single_config: called CC=3 SCAR=11.4
Pod
undocumented
Branch: 1 branch
Condition33%1/3
$check ||= do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::read_single_config", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
MC/DC0%0/2
$check ||= do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::read_single_config", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
$check
do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::read_single_config", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
Truth table33%1/3
A ||= B
A= $checkB= do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::read_single_config", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | ▶ | if ( $file =~ /\.json$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | my $decode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | eval { require JSON::MaybeXS } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | ? \&JSON::MaybeXS::decode_json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | : do { require JSON::PP; \&JSON::PP::decode_json }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | return $decode->( $file->slurp_utf8 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | elsif ( $file =~ /\.ya?ml/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | my $decode = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | eval { require YAML::XS } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ? \&YAML::XS::LoadFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | : do { require YAML::PP; \&YAML::PP::LoadFile }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return $decode->( $file->slurp_utf8 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | elsif ( $file =~ /\.ini/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | require Config::Tiny; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $cfg = 'Config::Tiny'->read( "$file", 'utf8' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $cfg->{'globals'} ||= delete $cfg->{'_'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$cfg->{"globals"} ||= delete $cfg->{"_"}
MC/DC0%0/2
$cfg->{"globals"} ||= delete $cfg->{"_"}
$cfg->{"globals"}
delete $cfg->{"_"}
Truth table0%0/3
A ||= B
A= $cfg->{"globals"}B= delete $cfg->{"_"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | return +{%$cfg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | require TOML::Parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | my $parser = 'TOML::Parser'->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | return $parser->parse_fh( $file->openr_utf8 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | method 'kingpin' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | my ( $app ) = ( shift->_proto ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kingpin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | my $kingpin = 'Getopt::Kingpin'->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | my $config = $app->read_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my @commands = $app->commands; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | for my $cmd ( @commands ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | ▶ | my $class = $app->get_class( $cmd ) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | ▶ | my $cmdname = $class->command_name or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | ▶ | my $cmdconfig = $config->{$cmdname} || {} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$config->{$cmdname} || {}
MC/DC0%0/1
$config->{$cmdname} || {}
$config->{$cmdname}
Truth table50%1/2
A
A= $config->{$cmdname}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | ▶ | my $globalconfig = $config->{'globals'} || {} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$config->{'globals'} || {}
MC/DC0%0/1
$config->{'globals'} || {}
$config->{'globals'}
Truth table50%1/2
A
A= $config->{'globals'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | $class->kingpin( $kingpin, { %$globalconfig, %$cmdconfig } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $kingpin->terminate( sub { $app->exit( $_[1] or 0 ) } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Condition0%0/2
$_[1] || 0
MC/DC0%0/1
$_[1] || 0
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | return $kingpin; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | method 'execute_no_subcommand' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | my ( $app, @args ) = ( shift->_proto, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_no_subcommand: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $app->execute( '--help' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | ▶ | run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | ▶ | my ( $app, @args ) = ( shift->_proto, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 1 | my $kingpin = $app->kingpin(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # Shortcut for the case of there only being one real command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | ▶ | if ( $kingpin->commands->count == 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | my @commands = grep $_->name ne 'help', $kingpin->commands->get_all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | my @realargs = grep !/^-/, @args; # naive, but should be okay | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | ▶ | unless ( @realargs and $realargs[0] eq $commands[0]->name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@realargs and $realargs[0] eq $commands[0]->name
MC/DC0%0/2
@realargs and $realargs[0] eq $commands[0]->name
@realargs
$realargs[0] eq $commands[0]->name
Truth table33%1/3
A and B
A= @realargsB= $realargs[0] eq $commands[0]->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | unshift @args, $commands[0]->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | my $cmd = $kingpin->parse( @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | my $cmd_class = $cmd->{'zylite_app_class'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | ▶ | if ( not $cmd_class ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $app->execute_no_subcommand( @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | my %flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | for my $name ( $cmd->flags->keys ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | my $flag = $cmd->flags->get( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 3 | ▶ | $flag->{'_defined'} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 3 | $flags{$name} = $flag->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | my $cmd_object = $cmd_class->new( %flags, _app => $app ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | my @coerced = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | my @values = map $_->value, $cmd->args->get_all; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | ▶ | my @args = map @{ $_ or {} }, $cmd_object->_args_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ || {}
MC/DC0%0/1
$_ || {}
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | my @return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | ▶ | while ( @values ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | my $value = shift @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | my $spec = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | ▶ | if ( $spec->{type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | $value = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | $spec->{type}->has_coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | ? $spec->{type}->assert_coerce( $value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | ▶ | : $spec->{type}->assert_return( $value ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 1 | push @return, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } #/ while ( @values ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 1 | @return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 1 | my $return = $cmd_object->execute( @coerced ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 1 | $app->exit( $return ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | method 'exit' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | => [ Int ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 1 | ▶ | my ( $self, $code ) = ( shift, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exit: called CC=3 SCAR=11.4
Pod
undocumented
Branch: 1 branch
Condition33%1/3
$check ||= do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::exit", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
MC/DC0%0/2
$check ||= do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::exit", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
$check
do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::exit", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
Truth table33%1/3
A ||= B
A= $checkB= do {
my $tmp = "MooX::Press"->_build_method_signature_check("Zydeco::Lite::App::Trait::Application", "Zydeco::Lite::App::Trait::Application::exit", "positional", $signature, \@invocants);
ref $tmp eq "HASH" ? $tmp->{"closure"} : $tmp
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | return CORE::exit( $code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | method 'stdin' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stdin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | ref( $self ) && exists( $self->{stdin} ) ? $self->{stdin} : \*STDIN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $self and exists $self->{"stdin"}
MC/DC0%0/2
ref $self and exists $self->{"stdin"}
ref $self
exists $self->{"stdin"}
Truth table0%0/3
A and B
A= ref $selfB= exists $self->{"stdin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | method 'stdout' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 12 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stdout: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 12 | ▶ | ref( $self ) && exists( $self->{stdout} ) ? $self->{stdout} : \*STDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $self and exists $self->{"stdout"}
MC/DC0%0/2
ref $self and exists $self->{"stdout"}
ref $self
exists $self->{"stdout"}
Truth table33%1/3
A and B
A= ref $selfB= exists $self->{"stdout"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | method 'stderr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stderr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | ref( $self ) && exists( $self->{stderr} ) ? $self->{stderr} : \*STDERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $self and exists $self->{"stderr"}
MC/DC0%0/2
ref $self and exists $self->{"stderr"}
ref $self
exists $self->{"stderr"}
Truth table0%0/3
A and B
A= ref $selfB= exists $self->{"stderr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | method 'readline' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | my $in = shift->stdin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readline: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $line = <$in>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | method 'print' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 12 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 12 | $self->stdout->print( "$_\n" ) for @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | method 'debug_mode' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_mode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | method 'debug' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | my $self = shift->_proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | return unless $self->debug_mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $self->stderr->print( "$_\n" ) for @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | method 'usage' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $self->stderr->print( "$_\n" ) for @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $self->exit( 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | my %colours = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | info => 'bright_blue', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | warn => 'bold bright_yellow', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | error => 'bold bright_red', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | fatal => 'bold bright_red', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | success => 'bold bright_green', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 2 | for my $key ( keys %colours ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 10 | my $level = $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 10 | my $colour = $colours{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | method $level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | require Term::ANSIColor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Subroutine
fatal: not called CC=1 SCAR=6.9
Subroutine
info: not called CC=1 SCAR=6.9
Subroutine
success: not called CC=1 SCAR=6.9
Subroutine
warn: not called CC=1 SCAR=6.9
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $self->stderr->print( Term::ANSIColor::colored( "$_\n", $colour ) ) for @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | $self->exit( 254 ) if $level eq 'fatal'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } #/ for my $key ( keys %colours) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | role 'Trait::Command' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 2 | requires qw( _flags_spec _args_spec execute command_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | has 'app' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | isa => ClassName | Object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | default => sub { shift->FACTORY }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 2 | handles => { map +( $_ => $_ ), qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | print debug info warn error fatal usage readline success | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | init_arg => '_app', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | has 'config' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | type => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $config = $self->app->read_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | my %config = ( %{ $config->{'globals'} or {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{'globals'} || {}
MC/DC0%0/1
$config->{'globals'} || {}
$config->{'globals'}
Truth table0%0/2
A
A= $config->{'globals'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | %{ $config->{ $self->command_name } or {} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$config{$self->command_name} || {}
MC/DC0%0/1
$$config{$self->command_name} || {}
$$config{$self->command_name}
Truth table0%0/2
A
A= $$config{$self->command_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | \%config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | method 'documentation' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | ▶ | return 'No description available.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
documentation: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | method 'kingpin' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | ▶ | => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | ▶ | my ( $class, $kingpin, $defaults ) = ( shift, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kingpin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | my $cmd = $kingpin->command( $class->command_name, $class->documentation ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | $cmd->{'zylite_app_class'} = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 1 | ▶ | my %specs = map %{ $_ or {} }, $class->_flags_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ || {}
MC/DC0%0/1
$_ || {}
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | for my $s ( sort keys %specs ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 2 | my $spec = $specs{$s}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 2 | my $flag = $spec->{'kingpin'}( $cmd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 2 | ▶ | if ( exists $defaults->{ $flag->name } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 2 | $flag->default( $defaults->{ $flag->name } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | ▶ | my @args = map @{ $_ or {} }, $class->_args_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ || {}
MC/DC0%0/1
$_ || {}
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | for my $spec ( @args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 1 | $spec->{'kingpin'}( $cmd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 1 | return $cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 2 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||