| 1 | package Spoon::Command; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Spoon::Base -Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | |||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | field quiet => 0; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: not called CC=4 SCAR=26.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 0 | ▶ | local *boolean_arguments = sub { qw( -q -quiet ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 9 | 0 | my ($args, @values) = $self->parse_arguments(@_); | |||||||||||||||||||||||||||
| 10 | $self->quiet(1) | ||||||||||||||||||||||||||||
| 11 | 0 | ▶ | if $args->{-q} || $args->{-quiet}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"-q"} or $args->{"-quiet"}
MC/DC0%0/2
$args->{"-q"} or $args->{"-quiet"}
$args->{"-q"}
$args->{"-quiet"}
Truth table0%0/3
A or B
A= $args->{"-q"}B= $args->{"-quiet"}
| |||||||||||||||||||||||||||||
| 12 | my $action = $self->get_action(shift(@values)) || | ||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub { $self->default_action(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$self->get_action(shift @values) || sub {
$self->default_action(@_);
}
MC/DC0%0/2
$self->get_action(shift @values) || sub {
$self->default_action(@_);
}
$self->get_action(shift @values)
sub {
$self->default_action(@_);
}
Truth table0%0/3
A || B
A= $self->get_action(shift @values)B= sub {
$self->default_action(@_);
}
| |||||||||||||||||||||||||||||
| 14 | 0 | $action->(@values); | |||||||||||||||||||||||||||
| 15 | 0 | return $self; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub get_action { | ||||||||||||||||||||||||||
|
Subroutine
get_action: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | my $action = shift | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | or return; | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $action =~ s/^-// | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | or return; | ||||||||||||||||||||||||||||
| 23 | 0 | my $method = "handle_$action"; | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 25 | 0 | $self->$method(@_); | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | } if $self->can($method); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $array = $self->hub->registry->lookup->{command}{$action} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | or return; | ||||||||||||||||||||||||||||
| 29 | 0 | my $class_id = shift @$array; | |||||||||||||||||||||||||||
| 30 | 0 | my $object = $self->hub->$class_id; | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 32 | 0 | $object->$method(@_); | |||||||||||||||||||||||||||
| 33 | 0 | }; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub default_action { | ||||||||||||||||||||||||||
|
Subroutine
default_action: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 0 | $self->usage; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub command_usage { | ||||||||||||||||||||||||||
|
Subroutine
command_usage: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | my $pattern = shift; | |||||||||||||||||||||||||||
| 42 | 0 | my $lookup = $self->hub->registry->lookup; | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $commands = $lookup->{command} || {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$lookup->{'command'} || {}
MC/DC0%0/1
$lookup->{'command'} || {}
$lookup->{'command'}
Truth table0%0/2
A
A= $lookup->{'command'}
| |||||||||||||||||||||||||||||
| 44 | my %descriptions = map { | ||||||||||||||||||||||||||||
| 45 | 0 | my $array = $commands->{$_}; | |||||||||||||||||||||||||||
| 46 | 0 | shift @$array; | |||||||||||||||||||||||||||
| 47 | 0 | my %hash = @$array; | |||||||||||||||||||||||||||
| 48 | 0 | ▶ | my $description = $hash{description} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$hash{'description'} || ''
MC/DC0%0/1
$hash{'description'} || ''
$hash{'description'}
Truth table0%0/2
A
A= $hash{'description'}
| |||||||||||||||||||||||||||||
| 49 | 0 | ($_, $description); | |||||||||||||||||||||||||||
| 50 | } keys %$commands; | ||||||||||||||||||||||||||||
| 51 | 0 | my $usage = ''; | |||||||||||||||||||||||||||
| 52 | 0 | for my $plugin (@{$lookup->plugins}) { | |||||||||||||||||||||||||||
| 53 | 0 | my $class_id = $plugin->{id}; | |||||||||||||||||||||||||||
| 54 | 0 | for my $command (@{$lookup->add_order->{$class_id}{command}}) { | |||||||||||||||||||||||||||
| 55 | 0 | $usage .= sprintf($pattern, $command, $descriptions{$command}); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 0 | return $usage; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub msg { | ||||||||||||||||||||||||||
|
Subroutine
msg: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | warn @_ unless $self->quiet; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1 | __DATA__ | |||||||||||||||||||||||||||