File Coverage

blib/lib/Footprintless/App/Action.pm
Criterion Covered Total %
statement 21 34 61.7
branch 0 2 0.0
condition 0 3 0.0
subroutine 8 13 61.5
pod 7 7 100.0
total 36 59 61.0


line stmt bran cond sub pod time code
1 5     5   1268 use strict;
  5         11  
  5         114  
2 5     5   21 use warnings;
  5         10  
  5         201  
3              
4             package Footprintless::App::Action;
5             $Footprintless::App::Action::VERSION = '1.26';
6             # ABSTRACT: A base class for actions
7             # PODNAME: Footprintless::App::Action
8              
9 5     5   23 use parent qw(App::Cmd::ArgProcessor);
  5         7  
  5         32  
10              
11 5     5   276 use Footprintless::App -ignore;
  5         9  
  5         28  
12 5     5   830 use Log::Any;
  5         7  
  5         22  
13              
14             my $logger = Log::Any->get_logger();
15              
16             sub _new {
17 8     8   21 my ( $class, $self ) = @_;
18 8         50 return bless( $self, $class );
19             }
20              
21             sub abstract {
22 0     0 1 0 my ($self_or_class) = @_;
23              
24 0         0 require Footprintless::App::DocumentationUtil;
25 0         0 return Footprintless::App::DocumentationUtil::abstract($self_or_class);
26             }
27              
28             sub description {
29 0     0 1 0 my ($self_or_class) = @_;
30              
31 0         0 require Footprintless::App::DocumentationUtil;
32 0   0     0 my $description = Footprintless::App::DocumentationUtil::description($self_or_class)
33             || ucfirst( $self_or_class->abstract() );
34              
35 0 0       0 if ( scalar( $self_or_class->opt_spec() ) ) {
36 0         0 $description .= "\n\nAvailable options:\n";
37             }
38              
39 0         0 return $description;
40             }
41              
42             sub prepare {
43 8     8 1 25 my ( $class, $app, $footprintless, $coordinate, @args ) = @_;
44              
45 8         33 my ( $opts, $remaining_args, %fields ) =
46             $class->_process_args( \@args, $class->usage_desc(), $class->opt_spec() );
47              
48             return (
49 8         3299 $class->_new(
50             { app => $app,
51             footprintless => $footprintless,
52             coordinate => $coordinate,
53             %fields
54             }
55             ),
56             $opts,
57             $remaining_args
58             );
59             }
60              
61             sub opt_spec {
62 3     3 1 17 return ();
63             }
64              
65             sub usage {
66 0     0 1   return $_[0]->{usage};
67             }
68              
69             sub usage_error {
70 0     0 1   my ( $self, $message, $coordinate ) = @_;
71 0           require Footprintless::App::UsageException;
72 0           die( Footprintless::App::UsageException->new( $message, $coordinate ) );
73             }
74              
75       0 1   sub validate_args { }
76              
77             1;
78              
79             __END__