| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Beam::Runner::Command::run; | 
| 2 |  |  |  |  |  |  | our $VERSION = '0.014'; | 
| 3 |  |  |  |  |  |  | # ABSTRACT: Run the given service with the given arguments | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | #pod =head1 SYNOPSIS | 
| 6 |  |  |  |  |  |  | #pod | 
| 7 |  |  |  |  |  |  | #pod     beam run   [] | 
| 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, L, L | 
| 16 |  |  |  |  |  |  | #pod | 
| 17 |  |  |  |  |  |  | #pod =cut | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 1 |  |  | 1 |  | 15471 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 20 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 21 | 1 |  |  | 1 |  | 355 | use Beam::Wire; | 
|  | 1 |  |  |  |  | 322879 |  | 
|  | 1 |  |  |  |  | 34 |  | 
| 22 | 1 |  |  | 1 |  | 8 | use Path::Tiny qw( path ); | 
|  | 1 |  |  |  |  | 7 |  | 
|  | 1 |  |  |  |  | 54 |  | 
| 23 | 1 |  |  | 1 |  | 5 | use Scalar::Util qw( blessed ); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 35 |  | 
| 24 | 1 |  |  | 1 |  | 290 | use Beam::Runner::Util qw( find_container_path ); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 150 |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub run { | 
| 27 | 5 |  |  | 5 | 0 | 12112 | my ( $class, $container, $service_name, @args ) = @_; | 
| 28 | 5 |  |  |  |  | 22 | my $path = find_container_path( $container ); | 
| 29 | 4 |  |  |  |  | 99 | my $wire = Beam::Wire->new( | 
| 30 |  |  |  |  |  |  | file => $path, | 
| 31 |  |  |  |  |  |  | ); | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 4 |  |  |  |  | 76416 | my $service = eval { $wire->get( $service_name ) }; | 
|  | 4 |  |  |  |  | 21 |  | 
| 34 | 4 | 100 |  |  |  | 7915 | if ( $@ ) { | 
| 35 | 2 | 100 | 33 |  |  | 227 | if ( blessed $@ && $@->isa( 'Beam::Wire::Exception::NotFound' ) && $@->name eq $service_name ) { | 
|  |  |  | 66 |  |  |  |  | 
| 36 | 1 |  |  |  |  | 7 | die sprintf qq{Could not find service "%s" in container "%s"\n}, | 
| 37 |  |  |  |  |  |  | $service_name, $path; | 
| 38 |  |  |  |  |  |  | } | 
| 39 | 1 |  |  |  |  | 32 | die sprintf qq{Could not load service "%s" in container "%s": %s\n}, $service_name, $path, $@; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 2 |  |  |  |  | 12 | return $service->run( @args ); | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | 1; | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | __END__ |