line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Role::Base; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
15
|
|
|
15
|
|
12414
|
use 5.010; |
|
15
|
|
|
|
|
60
|
|
6
|
15
|
|
|
15
|
|
100
|
use utf8; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
130
|
|
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
438
|
use namespace::autoclean; |
|
15
|
|
|
|
|
39
|
|
|
15
|
|
|
|
|
173
|
|
9
|
15
|
|
|
15
|
|
1437
|
use Moose::Role; |
|
15
|
|
|
|
|
48
|
|
|
15
|
|
|
|
|
160
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub initialize_command_class { |
12
|
74
|
|
|
74
|
0
|
243
|
my ($class,$command_class,%args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
74
|
|
|
|
|
294
|
my $meta = $class->meta; |
15
|
|
|
|
|
|
|
|
16
|
74
|
50
|
|
|
|
1702
|
Moose->throw_error('initialize_command_class is a class method') |
17
|
|
|
|
|
|
|
if blessed($class); |
18
|
|
|
|
|
|
|
|
19
|
74
|
|
|
|
|
795
|
my ($ok,$error) = Class::Load::try_load_class($command_class); |
20
|
74
|
50
|
|
|
|
2958
|
unless ($ok) { |
21
|
0
|
|
|
|
|
0
|
Moose->throw_error($error); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
74
|
|
33
|
|
|
354
|
my $command_meta = $command_class->meta || $meta; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Build MooseX::App::ParsedArgv and set hints |
27
|
74
|
|
|
|
|
1706
|
my $parsed_argv = MooseX::App::ParsedArgv->instance(); |
28
|
74
|
|
|
|
|
391
|
my $hints = $meta->command_parser_hints($command_meta); |
29
|
74
|
|
|
|
|
2837
|
$parsed_argv->hints_fixedvalue($hints->{fixedvalue}); |
30
|
74
|
|
|
|
|
2502
|
$parsed_argv->hints_novalue($hints->{novalue}); |
31
|
74
|
100
|
|
|
|
2679
|
if ($meta->app_permute) { |
32
|
34
|
|
|
|
|
1004
|
$parsed_argv->hints_permute($hints->{permute}); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
74
|
|
|
|
|
417
|
my ($proto_result,$proto_errors) = $meta->command_proto($command_meta); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# TODO return some kind of null class object |
38
|
|
|
|
|
|
|
return |
39
|
74
|
50
|
|
|
|
289
|
unless defined $proto_result; |
40
|
|
|
|
|
|
|
|
41
|
74
|
|
|
|
|
162
|
my @errors = @{$proto_errors}; |
|
74
|
|
|
|
|
198
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Return user-requested help |
44
|
74
|
100
|
|
|
|
256
|
if ($proto_result->{help_flag}) { |
45
|
6
|
|
|
|
|
37
|
return MooseX::App::Message::Envelope->new( |
46
|
|
|
|
|
|
|
$meta->command_usage_command($command_class->meta), |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
68
|
|
|
|
|
353
|
my ($result,$errors) = $meta->command_args($command_meta); |
51
|
67
|
|
|
|
|
165
|
push(@errors,@{$errors}); |
|
67
|
|
|
|
|
142
|
|
52
|
|
|
|
|
|
|
|
53
|
67
|
|
|
|
|
146
|
my %params; |
54
|
67
|
100
|
|
|
|
2437
|
if ($meta->app_prefer_commandline) { |
55
|
|
|
|
|
|
|
%params = ( |
56
|
|
|
|
|
|
|
%args, # configs passed to new |
57
|
7
|
|
|
|
|
17
|
%{ $proto_result }, # config params |
58
|
7
|
|
|
|
|
22
|
%{ $result }, # params from CLI |
|
7
|
|
|
|
|
36
|
|
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} else { |
61
|
|
|
|
|
|
|
%params = ( |
62
|
60
|
|
|
|
|
192
|
%{ $proto_result }, # config params |
63
|
60
|
|
|
|
|
145
|
%{ $result }, # params from CLI |
|
60
|
|
|
|
|
305
|
|
64
|
|
|
|
|
|
|
%args, # configs passed to new |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
67
|
|
|
|
|
451
|
$meta->command_check_attributes($command_meta,\@errors,\%params); |
69
|
|
|
|
|
|
|
|
70
|
67
|
100
|
|
|
|
237
|
if (scalar @errors) { |
71
|
23
|
|
|
|
|
157
|
return MooseX::App::Message::Envelope->new( |
72
|
|
|
|
|
|
|
@errors, |
73
|
|
|
|
|
|
|
$meta->command_usage_command($command_meta), |
74
|
|
|
|
|
|
|
1, # exitcode |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
44
|
|
|
|
|
343
|
my $command_object = $command_class->new( |
79
|
|
|
|
|
|
|
%params, |
80
|
|
|
|
|
|
|
extra_argv => [ $parsed_argv->extra ], |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
44
|
50
|
|
|
|
89483
|
if (scalar @errors) { |
84
|
0
|
|
|
|
|
0
|
return MooseX::App::Message::Envelope->new( |
85
|
|
|
|
|
|
|
@errors, |
86
|
|
|
|
|
|
|
$meta->command_usage_command($command_meta), |
87
|
|
|
|
|
|
|
1, # exitcode |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
44
|
|
|
|
|
600
|
return $command_object; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |