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