| 1 | package Beam::Runner::Command::run; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | our $VERSION = '0.016'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Run the given service with the given arguments | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | #pod =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 6 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 7 | #pod beam run <container> <service> [<args...>] | ||||||||||||||||||||||||||||||||||||||||||
| 8 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 9 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 10 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 11 | #pod Run a service from the given container, passing in any arguments. | ||||||||||||||||||||||||||||||||||||||||||
| 12 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 13 | #pod =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 14 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 15 | #pod L<beam>, L<Beam::Runner::Command>, L<Beam::Runner> | ||||||||||||||||||||||||||||||||||||||||||
| 16 | #pod | ||||||||||||||||||||||||||||||||||||||||||
| 17 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Beam::Wire; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Path::Tiny qw( path ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Beam::Runner::Util qw( find_container_path ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | my ( $class, $container, $service_name, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | my $path = find_container_path( $container ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | my $wire = Beam::Wire->new( | |||||||||||||||||||||||||||||||||||||||||
| 30 | file => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | my $service = eval { $wire->get( $service_name ) }; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | if ( blessed $@ && $@->isa( 'Beam::Wire::Exception::NotFound' ) && $@->name eq $service_name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
builtin::blessed($@) and $@->isa("Beam::Wire::Exception::NotFound") and $@->name eq $service_name
builtin::blessed($@) and $@->isa("Beam::Wire::Exception::NotFound")
MC/DC33%1/3
builtin::blessed($@) and $@->isa("Beam::Wire::Exception::NotFound") and $@->name eq $service_name
builtin::blessed($@)
$@->isa("Beam::Wire::Exception::NotFound")
$@->name eq $service_name
Truth table50%2/4
A and B and C
A= builtin::blessed($@)B= $@->isa("Beam::Wire::Exception::NotFound")C= $@->name eq $service_name
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | die sprintf qq{Could not find service "%s" in container "%s"\n}, | |||||||||||||||||||||||||||||||||||||||||
| 37 | $service_name, $path; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | die sprintf qq{Could not load service "%s" in container "%s": %s\n}, $service_name, $path, $@; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | return $service->run( @args ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||||||||||||||||||||||||||