File Coverage

blib/lib/CLI/Osprey/InlineSubcommand.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package CLI::Osprey::InlineSubcommand;
2 4     4   28 use strict;
  4         11  
  4         130  
3 4     4   22 use warnings;
  4         7  
  4         116  
4 4     4   23 use Moo;
  4         11  
  4         27  
5              
6             # ABSTRACT: A class to wrap coderef subcommands
7             our $VERSION = '0.08'; # VERSION
8             our $AUTHORITY = 'cpan:ARODLAND'; # AUTHORITY
9              
10             has 'name' => (
11             is => 'ro',
12             required => 1,
13             );
14              
15             has 'desc' => (
16             is => 'bare',
17             reader => '_osprey_subcommand_desc',
18             );
19              
20             has 'method' => (
21             is => 'ro',
22             required => 1,
23             );
24              
25             has 'parent_command' => (
26             is => 'rw',
27             );
28              
29             has 'argv' => (
30             is => 'rw',
31             );
32              
33             sub new_with_options {
34 1     1 0 6 my ($self, %args) = @_;
35 1         13 $self->parent_command($args{ parent_command });
36 1         4 $self->argv([ @ARGV ]);
37 1         12 return $self;
38             }
39              
40             sub run {
41 1     1 0 2 my ($self) = @_;
42 1         4 my $cmd = $self->parent_command;
43 1         4 my $method = $self->method;
44              
45 1         3 @_ = ($self->parent_command, @{ $self->argv });
  1         5  
46 1         10 goto &$method;
47             }
48              
49 4     4   2348 no Moo;
  4         9  
  4         21  
50             1;
51              
52             __END__