| 1 | package Getopt::Chain::Declare; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | Getopt::Chain::Declare - Option and subcommand processing in the style of svn and git | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 SYNPOSIS | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | package My::Command; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | use Getopt::Chain::Declare; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | start [qw/ verbose|v /]; # These are "global" | ||||||||||||||||||||||||||||
| 17 | # my-command --verbose ... | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # my-command ? initialize ... --> my-command help initialize ... | ||||||||||||||||||||||||||||
| 20 | rewrite qr/^\?(.*)/ => sub { "help ".($1||'') }; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # NOTE: Rewriting applies to the command sequence, NOT options | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # my-command about ... --> my-command help about | ||||||||||||||||||||||||||||
| 25 | rewrite [ ['about', 'copying'] ] => sub { "help $1" }; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # my-command initialize --dir=... | ||||||||||||||||||||||||||||
| 28 | on initialize => [qw/ dir|d=s /], sub { | ||||||||||||||||||||||||||||
| 29 | my $context = shift; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | my $dir = $context->option( 'dir' ) | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # Do initialize stuff with $dir | ||||||||||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # my-command help | ||||||||||||||||||||||||||||
| 37 | on help => undef, sub { | ||||||||||||||||||||||||||||
| 38 | my $context = shift; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # Do help stuff ... | ||||||||||||||||||||||||||||
| 41 | # First argument is undef because help | ||||||||||||||||||||||||||||
| 42 | # doesn't take any options | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | under help => sub { | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # my-command help create | ||||||||||||||||||||||||||||
| 49 | # my-command help initialize | ||||||||||||||||||||||||||||
| 50 | on [ [ qw/create initialize/ ] ] => undef, sub { | ||||||||||||||||||||||||||||
| 51 | my $context = shift; | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # Do help for create/initialize | ||||||||||||||||||||||||||||
| 54 | # Both: "help create" and "help initialize" go here | ||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # my-command help about | ||||||||||||||||||||||||||||
| 58 | on 'about' => undef, sub { | ||||||||||||||||||||||||||||
| 59 | my $context = shift; | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # Help for about... | ||||||||||||||||||||||||||||
| 62 | }; | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # my-command help copying | ||||||||||||||||||||||||||||
| 65 | on 'copying' => undef, sub { | ||||||||||||||||||||||||||||
| 66 | my $context = shift; | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # Help for copying... | ||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # my-command help ... | ||||||||||||||||||||||||||||
| 72 | on qr/^(\S+)$/ => undef, sub { | ||||||||||||||||||||||||||||
| 73 | my $context = shift; | ||||||||||||||||||||||||||||
| 74 | my $topic = $1; | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # Catch-all for anything not fitting into the above... | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | warn "I don't know about \"$topic\"\n" | ||||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # ... elsewhere ... | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | My::Command->new->run( [ @arguments ] ) | ||||||||||||||||||||||||||||
| 85 | My::Command->new->run # Just run with @ARGV | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | For more information, see L<Getopt::Chain> | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 5 | ▶ | use Moose(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 94 | 5 | ▶ | use Moose::Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 5 | Moose::Exporter->setup_import_methods( | |||||||||||||||||||||||||||
| 97 | with_caller => [qw/ context start on rewrite under /], | ||||||||||||||||||||||||||||
| 98 | also => [qw/ Moose /], | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub init_meta { | ||||||||||||||||||||||||||||
| 102 | 5 | ▶ | shift; | ||||||||||||||||||||||||||
|
Subroutine
init_meta: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 5 | return Moose->init_meta( @_, base_class => 'Getopt::Chain', metaclass => 'Getopt::Chain::Declare::Meta::Class' ); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | sub context { | ||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
context: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 108 | 0 | $caller->meta->context_from( @_ ); | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | sub start { | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | 0 | $caller->meta->start( @_ ); | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | sub on { | ||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
on: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 118 | 0 | $caller->meta->on( @_ ); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | sub under { | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
under: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 123 | 0 | $caller->meta->under( @_ ); | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | sub rewrite { | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
rewrite: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 0 | $caller->meta->rewrite( @_ ); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | package Getopt::Chain::Declare::Recorder; | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 5 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 134 | 5 | ▶ | use MooseX::AttributeHelpers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | ▶ | has _replay_list => qw/metaclass Collection::Array is ro isa ArrayRef/, default => sub { [] }, provides => {qw/ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 137 | push record | ||||||||||||||||||||||||||||
| 138 | elements replay_list | ||||||||||||||||||||||||||||
| 139 | /}; | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 5 | our $BUILDER; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub replay { | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
replay: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 145 | 0 | my $builder = shift; | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||
| 148 | 0 | local $BUILDER = $builder; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | for my $replay ($self->replay_list) { | |||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ( ref $replay eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | my @replay = @$replay; | |||||||||||||||||||||||||||
| 153 | 0 | my $method = shift @replay; | |||||||||||||||||||||||||||
| 154 | 0 | $builder->$method( @replay ); | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | else { | ||||||||||||||||||||||||||||
| 157 | # It's a "child" package | ||||||||||||||||||||||||||||
| 158 | 0 | $replay->replay( $builder ); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | sub do_or_record { | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
do_or_record: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | 0 | my $method = shift; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ($BUILDER) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | $BUILDER->$method( @_ ); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||
| 172 | 0 | $self->record( [ $method => @_ ] ); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | package Getopt::Chain::Declare::Meta::Class; | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 5 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 179 | 5 | ▶ | use MooseX::AttributeHelpers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 5 | extends qw/Moose::Meta::Class/; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 5 | has recorder => qw/is ro lazy_build 1/, handles => [qw/ replay do_or_record /]; | |||||||||||||||||||||||||||
| 184 | sub _build_recorder { | ||||||||||||||||||||||||||||
| 185 | 0 | ▶ | return Getopt::Chain::Declare::Recorder->new; | ||||||||||||||||||||||||||
|
Subroutine
_build_recorder: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | around new_object => sub { | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | my $around = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 190 | 0 | my $meta = shift; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | my @arguments = map { $_ => $meta->$_ } grep { defined $meta->$_ } qw/ context_from /; | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my $self = $around->( $meta, @arguments, 1 == @_ && ref $_[0] eq 'HASH' ? %{ $_[0] } : @_ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
1 == @_ and ref $_[0] eq "HASH"
MC/DC0%0/2
1 == @_ and ref $_[0] eq "HASH"
1 == @_
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= 1 == @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 195 | 0 | my $builder = $self->builder; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | $meta->recorder->replay( $builder ); | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | return $self; | |||||||||||||||||||||||||||
| 200 | 5 | }; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 5 | has context_from => qw/is rw/; | |||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub start { shift->do_or_record( start => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub on { shift->do_or_record( on => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
on: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub under { shift->do_or_record( under => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
under: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub rewrite { shift->do_or_record( rewrite => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
rewrite: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | package Getopt::Chain::Declare::Branch; | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 5 | ▶ | use Moose(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 211 | 5 | ▶ | use Moose::Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 5 | my %IMPORT_ARGUMENTS; # Yes, an ugly hack | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||
| 216 | 5 | my ($import, $unimport) = Moose::Exporter->build_import_methods( | |||||||||||||||||||||||||||
| 217 | with_caller => [qw/ start on rewrite under /], | ||||||||||||||||||||||||||||
| 218 | also => [qw/ Moose /], | ||||||||||||||||||||||||||||
| 219 | ); | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | sub import { | ||||||||||||||||||||||||||||
| 222 | 0 | ▶ | my $class = shift; # 'under' or 'redispatch' or ... | ||||||||||||||||||||||||||
|
Subroutine
import: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 223 | 0 | my $caller = caller(); | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | $IMPORT_ARGUMENTS{$caller} = [ @_ ]; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | goto &$import; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 5 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 231 | 5 | *unimport = $unimport; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | sub init_meta { | ||||||||||||||||||||||||||||
| 235 | 0 | ▶ | shift; | ||||||||||||||||||||||||||
|
Subroutine
init_meta: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 236 | 0 | return Moose->init_meta( @_, base_class => 'Getopt::Chain', metaclass => 'Getopt::Chain::Declare::Branch::Meta::Class' ); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | sub start { | ||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 241 | 0 | $caller->meta->start( @_ ); | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | sub on { | ||||||||||||||||||||||||||||
| 245 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
on: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 246 | 0 | $caller->meta->on( @_ ); | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | sub under { | ||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
under: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 251 | 0 | $caller->meta->under( @_ ); | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | sub rewrite { | ||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
rewrite: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 256 | 0 | $caller->meta->rewrite( @_ ); | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 5 | 1; | |||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | package Getopt::Chain::Declare::Branch::Meta::Class; | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 5 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 264 | 5 | ▶ | use Getopt::Chain::Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 5 | extends qw/Moose::Meta::Class/; | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 5 | has getopt_chain_parent_class => qw/is ro lazy_build 1/; | |||||||||||||||||||||||||||
| 269 | sub _build_getopt_chain_parent_class { | ||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_getopt_chain_parent_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 271 | 0 | my ($class) = $self->linearized_isa; | |||||||||||||||||||||||||||
| 272 | 0 | my @class = split m/::/, $class; | |||||||||||||||||||||||||||
| 273 | 0 | pop @class; | |||||||||||||||||||||||||||
| 274 | 0 | join '::', @class; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | sub getopt_chain_parent_meta { | ||||||||||||||||||||||||||||
| 278 | 0 | ▶ | return shift->getopt_chain_parent_class->meta; | ||||||||||||||||||||||||||
|
Subroutine
getopt_chain_parent_meta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | sub import_arguments { | ||||||||||||||||||||||||||||
| 282 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
import_arguments: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | my ($class) = $self->linearized_isa; | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 0 | ▶ | croak "No import arguments for \"$class\"" unless my $arguments = $IMPORT_ARGUMENTS{$class}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 0 | return @$arguments; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 5 | has recorder => qw/is ro lazy_build 1/, handles => [qw/ do_or_record /]; | |||||||||||||||||||||||||||
| 292 | sub _build_recorder { | ||||||||||||||||||||||||||||
| 293 | 0 | ▶ | require Getopt::Chain::Declare; | ||||||||||||||||||||||||||
|
Subroutine
_build_recorder: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 294 | 0 | return Getopt::Chain::Declare::Recorder->new; | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | sub replay { | ||||||||||||||||||||||||||||
| 298 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
replay: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 299 | 0 | my $parent_builder = shift; | |||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 0 | my @arguments = $self->import_arguments; | |||||||||||||||||||||||||||
| 302 | 0 | my $match = $arguments[0]; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | # We *could* redispatch here, but ... | ||||||||||||||||||||||||||||
| 305 | $parent_builder->under( $match => sub { | ||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $self->recorder->replay( $parent_builder ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 307 | 0 | } ); | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 5 | has registered => qw/is rw default 0/; | |||||||||||||||||||||||||||
| 311 | before do_or_record => sub { | ||||||||||||||||||||||||||||
| 312 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 313 | 0 | ▶ | return if $self->registered; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | 0 | $self->getopt_chain_parent_meta->recorder->record( $self ); # "Register" ourself | |||||||||||||||||||||||||||
| 315 | 0 | $self->registered( 1 ); | |||||||||||||||||||||||||||
| 316 | 5 | }; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | sub start { shift->do_or_record( start => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub on { shift->do_or_record( on => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
on: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub under { shift->do_or_record( under => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
under: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | sub rewrite { shift->do_or_record( rewrite => @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
rewrite: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 5 | 1; | |||||||||||||||||||||||||||