line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Role::Base; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
10374
|
use 5.010; |
|
14
|
|
|
|
|
42
|
|
6
|
14
|
|
|
14
|
|
63
|
use utf8; |
|
14
|
|
|
|
|
22
|
|
|
14
|
|
|
|
|
103
|
|
7
|
|
|
|
|
|
|
|
8
|
14
|
|
|
14
|
|
351
|
use namespace::autoclean; |
|
14
|
|
|
|
|
19
|
|
|
14
|
|
|
|
|
120
|
|
9
|
14
|
|
|
14
|
|
1233
|
use Moose::Role; |
|
14
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
133
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub initialize_command_class { |
12
|
74
|
|
|
74
|
0
|
189
|
my ($class,$command_class,%args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
74
|
|
|
|
|
320
|
my $meta = $class->meta; |
15
|
|
|
|
|
|
|
|
16
|
74
|
50
|
|
|
|
1485
|
Moose->throw_error('initialize_command_class is a class method') |
17
|
|
|
|
|
|
|
if blessed($class); |
18
|
|
|
|
|
|
|
|
19
|
74
|
|
|
|
|
371
|
my ($ok,$error) = Class::Load::try_load_class($command_class); |
20
|
74
|
50
|
|
|
|
2701
|
unless ($ok) { |
21
|
0
|
|
|
|
|
0
|
Moose->throw_error($error); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
74
|
|
33
|
|
|
348
|
my $command_meta = $command_class->meta || $meta; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Build MooseX::App::ParsedArgv and set hints |
27
|
74
|
|
|
|
|
1214
|
my $parsed_argv = MooseX::App::ParsedArgv->instance(); |
28
|
74
|
|
|
|
|
386
|
my $hints = $meta->command_parser_hints($command_meta); |
29
|
74
|
|
|
|
|
2686
|
$parsed_argv->hints_fixedvalue($hints->{fixedvalue}); |
30
|
74
|
|
|
|
|
2330
|
$parsed_argv->hints_novalue($hints->{novalue}); |
31
|
74
|
100
|
|
|
|
2530
|
if ($meta->app_permute) { |
32
|
34
|
|
|
|
|
917
|
$parsed_argv->hints_permute($hints->{permute}); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
74
|
|
|
|
|
425
|
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
|
|
|
|
243
|
unless defined $proto_result; |
40
|
|
|
|
|
|
|
|
41
|
74
|
|
|
|
|
101
|
my @errors = @{$proto_errors}; |
|
74
|
|
|
|
|
180
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Return user-requested help |
44
|
74
|
100
|
|
|
|
227
|
if ($proto_result->{help_flag}) { |
45
|
6
|
|
|
|
|
42
|
return MooseX::App::Message::Envelope->new( |
46
|
|
|
|
|
|
|
$meta->command_usage_command($command_class->meta), |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
68
|
|
|
|
|
352
|
my ($result,$errors) = $meta->command_args($command_meta); |
51
|
67
|
|
|
|
|
115
|
push(@errors,@{$errors}); |
|
67
|
|
|
|
|
162
|
|
52
|
|
|
|
|
|
|
|
53
|
67
|
|
|
|
|
103
|
my %params; |
54
|
67
|
100
|
|
|
|
2298
|
if ($meta->app_prefer_commandline) { |
55
|
|
|
|
|
|
|
%params = ( |
56
|
|
|
|
|
|
|
%args, # configs passed to new |
57
|
7
|
|
|
|
|
18
|
%{ $proto_result }, # config params |
58
|
7
|
|
|
|
|
20
|
%{ $result }, # params from CLI |
|
7
|
|
|
|
|
41
|
|
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} else { |
61
|
|
|
|
|
|
|
%params = ( |
62
|
60
|
|
|
|
|
172
|
%{ $proto_result }, # config params |
63
|
60
|
|
|
|
|
102
|
%{ $result }, # params from CLI |
|
60
|
|
|
|
|
309
|
|
64
|
|
|
|
|
|
|
%args, # configs passed to new |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
67
|
|
|
|
|
397
|
$meta->command_check_attributes($command_meta,\@errors,\%params); |
69
|
|
|
|
|
|
|
|
70
|
67
|
100
|
|
|
|
212
|
if (scalar @errors) { |
71
|
23
|
|
|
|
|
144
|
return MooseX::App::Message::Envelope->new( |
72
|
|
|
|
|
|
|
@errors, |
73
|
|
|
|
|
|
|
$meta->command_usage_command($command_meta), |
74
|
|
|
|
|
|
|
1, # exitcode |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
44
|
|
|
|
|
380
|
my $command_object = $command_class->new( |
79
|
|
|
|
|
|
|
%params, |
80
|
|
|
|
|
|
|
extra_argv => [ $parsed_argv->extra ], |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
44
|
50
|
|
|
|
68852
|
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
|
|
|
|
|
629
|
return $command_object; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |