| 1 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package Footprintless::App::Command::service; | ||||||||||||||||||||||||||||
| 5 | 5 | $Footprintless::App::Command::service::VERSION = '1.29'; | |||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Footprintless::App -command; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Footprintless::Util qw(exit_due_to); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Log::Any; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 5 | my $logger = Log::Any->get_logger(); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # ABSTRACT: Performs an action on one or more services. | ||||||||||||||||||||||||||||
| 13 | # PODNAME: Footprintless::App::Command::service | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=5 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 3 | my ( $self, $opts, $args ) = @_; | |||||||||||||||||||||||||||
| 17 | 3 | my ( $coordinate, $action ) = @$args; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | foreach my $target ( @{ $self->{targets} } ) { | |||||||||||||||||||||||||||
| 20 | 4 | $logger->debugf( 'executing %s for %s', $action, $target->{coordinate} ); | |||||||||||||||||||||||||||
| 21 | 4 | eval { $target->execute($action); }; | |||||||||||||||||||||||||||
| 22 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if ( ref($@) && $@->isa('Footprintless::InvalidEntityException') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $@ and $@->isa("Footprintless::InvalidEntityException")
MC/DC0%0/2
ref $@ and $@->isa("Footprintless::InvalidEntityException")
ref $@
$@->isa("Footprintless::InvalidEntityException")
Truth table0%0/3
A and B
A= ref $@B= $@->isa("Footprintless::InvalidEntityException")
| |||||||||||||||||||||||||||||
| 24 | 0 | $self->usage_error($@); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | 0 | exit_due_to( $@, 1 ); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 3 | ▶ | sub usage_desc { | ||||||||||||||||||||||||||
|
Subroutine
usage_desc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 3 | return "fpl service SERVICE_COORD ACTION"; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 3 | ▶ | sub validate_args { | ||||||||||||||||||||||||||
|
Subroutine
validate_args: called CC=8 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 3 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 37 | 3 | my ( $coordinate, $action, @sub_coordinates ) = @$args; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 3 | ▶ | $self->usage_error("coordinate is required") unless ($coordinate); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 3 | ▶ | $self->usage_error("action is required") unless ($action); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 3 | my $footprintless = $self->app()->footprintless(); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | my @target_coordinates = | ||||||||||||||||||||||||||||
| 45 | @sub_coordinates | ||||||||||||||||||||||||||||
| 46 | 3 | ▶ | ? map {"$coordinate.$_"} @sub_coordinates | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | : ($coordinate); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 3 | my @targets = (); | |||||||||||||||||||||||||||
| 50 | 3 | foreach my $target_coordinate (@target_coordinates) { | |||||||||||||||||||||||||||
| 51 | 4 | eval { push( @targets, $footprintless->service($target_coordinate) ); }; | |||||||||||||||||||||||||||
| 52 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( ref($@) && $@->isa('Footprintless::InvalidEntityException') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $@ and $@->isa("Footprintless::InvalidEntityException")
MC/DC0%0/2
ref $@ and $@->isa("Footprintless::InvalidEntityException")
ref $@
$@->isa("Footprintless::InvalidEntityException")
Truth table0%0/3
A and B
A= ref $@B= $@->isa("Footprintless::InvalidEntityException")
| |||||||||||||||||||||||||||||
| 54 | 0 | $self->usage_error($@); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||
| 57 | 0 | $self->usage_error("invalid coordinate [$target_coordinate]: $@"); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 3 | $self->{targets} = \@targets; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 5 | 1; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||