File Coverage

blib/lib/Beam/Runner/Command/help.pm
Criterion Covered Total %
statement 32 32 100.0
branch 6 6 100.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 0 1 0.0
total 48 49 97.9


line stmt bran cond sub pod time code
1             package Beam::Runner::Command::help;
2             our $VERSION = '0.014';
3             # ABSTRACT: Get help for the given service(s)
4              
5             #pod =head1 SYNOPSIS
6             #pod
7             #pod beam help
8             #pod
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod Show the documentation for the given service from the given container.
12             #pod
13             #pod =head1 SEE ALSO
14             #pod
15             #pod L, L, L
16             #pod
17             #pod =cut
18              
19 1     1   79855 use strict;
  1         2  
  1         24  
20 1     1   5 use warnings;
  1         1  
  1         24  
21 1     1   297 use Beam::Runner::Util qw( find_container_path );
  1         4  
  1         67  
22 1     1   313 use Pod::Usage qw( pod2usage );
  1         37254  
  1         91  
23 1     1   13 use Pod::Find qw( pod_where );
  1         3  
  1         54  
24 1     1   512 use Beam::Wire;
  1         417564  
  1         202  
25              
26             sub run {
27 6     6 0 24987 my ( $class, $container, $service_name ) = @_;
28              
29 6 100 100     43 if ( !$container || !$service_name ) {
30 2         489 return pod2usage(
31             -message => 'ERROR: and are required',
32             -input => pod_where( { -inc => 1 }, __PACKAGE__ ),
33             -verbose => 0,
34             -exitval => 1,
35             );
36             }
37              
38 4         16 my $path = find_container_path( $container );
39 3         84 my $wire = Beam::Wire->new(
40             file => $path,
41             );
42 3         55360 my $service_conf = $wire->get_config( $service_name );
43 3 100       90 die sprintf qq{Could not find service "%s" in container "%s"\n},
44             $service_name, $path
45             unless $service_conf;
46              
47 2         5 my %service_conf = %{ $wire->normalize_config( $service_conf ) };
  2         8  
48 2         135 %service_conf = $wire->merge_config( %service_conf );
49 2         960 my $pod_path = pod_where( { -inc => 1 }, $service_conf{class} );
50 2 100       15 if ( !$pod_path ) {
51 1         12 die "Could not find documentation for class '$service_conf{class}'\n";
52             }
53             pod2usage(
54 1         11 -input => $pod_path,
55             -verbose => 2,
56             -exitval => 0,
57             );
58             }
59              
60             1;
61              
62             __END__