Extension/Component/RunCommand.pm

filter: Statementstmt 40.3% 21 / 52 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 5 / 15 Podpod 0.0% 0 / 6 totaltotal 33.7% 26 / 77 CC 3 SCAR 9.2
CC
3
Cov
38%
__ANON__
6.0
run_command
4.8
__ANON__
2.0
CRAP 2.5
« Extension/Component/InstallCallback.pm ↑ Summary Extension.pm »
1 package App::CLI::Extension::Component::RunCommand;
2  
3 =pod
4  
5 =head1 NAME
6  
7 App::CLI::Extension::Component::RunCommand - for App::CLI::Command run_command override module
8  
9 =head1 VERSION
10  
11 1.421
12  
13 =cut
14  
15 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 18 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 18 ▶use Error qw(:try);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 18 ▶use base qw(Class::Accessor::Grouped);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 18 our $FAIL_EXIT_VALUE = 255;
21 18 our $VERSION = '1.421';
22  
23 18 __PACKAGE__->mk_group_accessors(inherited => "e", "exit_value", "finished");
24 18 __PACKAGE__->exit_value(0);
25 18 __PACKAGE__->finished(0);
26  
27  
28 0 ▶sub run_command {
Subroutine run_command: not called CC=2 SCAR=15.6
Pod undocumented
29  
30 0 my($self, @argv) = @_;
31  
32 0 ▶ try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
33 0 $self->setup(@argv);
34 0 $self->prerun(@argv);
35 0 ▶ if ($self->finished == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->finished == 0) 0 0 0
36 0 $self->run(@argv);
37 0 $self->postrun(@argv);
38 }
39 }
40 0 ▶ catch App::CLI::Extension::Exception with {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 # $self->e is App::CLI::Extension::Exception object. execute $self->throw($message)
42 0 $self->e(shift);
43 0 $self->exit_value($FAIL_EXIT_VALUE);
44 0 $self->fail(@argv);
45 }
46 0 ▶ otherwise {
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 # $self->e is Error::Simple object
48 0 $self->e(shift);
49 0 $self->exit_value($FAIL_EXIT_VALUE);
50 0 $self->fail(@argv);
51 }
52 0 ▶ finally {
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 0 $self->finish(@argv);
54 0 };
55  
56 0 ▶ if (exists $ENV{APPCLI_NON_EXIT}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{'APPCLI_NON_EXIT'}) { } 0 0 0
57 18 ▶ no strict "refs"; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
58 0 my $dispatch_pkg = $self->app;
59 0 ${"$dispatch_pkg\::EXIT_VALUE"} = $self->exit_value;
60 } else {
61 0 exit $self->exit_value;
62 }
63 }
64  
65 #######################################
66 # for run_command method
67 #######################################
68  
69 0 ▶sub setup {
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
70  
71 0 my($self, @argv) = @_;
72 # something to do
73 0 $self->maybe::next::method(@argv);
74 }
75  
76 0 ▶sub prerun {
Subroutine prerun: not called CC=1 SCAR=6.9
Pod undocumented
77  
78 0 my($self, @argv) = @_;
79 # something to do
80 0 $self->maybe::next::method(@argv);
81 }
82  
83 0 ▶sub finish {
Subroutine finish: not called CC=1 SCAR=6.9
Pod undocumented
84  
85 0 my($self, @argv) = @_;
86 # something to do
87 0 $self->maybe::next::method(@argv);
88 }
89  
90 0 ▶sub postrun {
Subroutine postrun: not called CC=1 SCAR=6.9
Pod undocumented
91  
92 0 my($self, @argv) = @_;
93 # something to do
94 0 $self->maybe::next::method(@argv);
95 }
96  
97 0 ▶sub fail {
Subroutine fail: not called CC=1 SCAR=6.9
Pod undocumented
98  
99 0 my($self, @argv) = @_;
100 0 chomp(my $message = $self->e->stringify);
101 0 warn sprintf("default fail method. error message:%s. override fail method!!\n", $message);
102 0 $self->maybe::next::method(@argv);
103 }
104  
105 18 1;
106  
107 __END__
« Extension/Component/InstallCallback.pm ↑ Summary Extension.pm »