| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ============================================================================ |
|
2
|
|
|
|
|
|
|
package MooseX::App::Plugin::Config::Meta::Class; |
|
3
|
|
|
|
|
|
|
# ============================================================================ |
|
4
|
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
5346
|
use 5.010; |
|
|
6
|
|
|
|
|
26
|
|
|
6
|
6
|
|
|
6
|
|
45
|
use utf8; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
52
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
174
|
use namespace::autoclean; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
52
|
|
|
9
|
6
|
|
|
6
|
|
571
|
use Moose::Role; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
53
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
around 'command_proto' => sub { |
|
12
|
|
|
|
|
|
|
my ($orig,$self,$metaclass) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my ($result,$errors) = $self->$orig($metaclass); |
|
15
|
|
|
|
|
|
|
delete $result->{config} |
|
16
|
|
|
|
|
|
|
unless defined $result->{config}; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return $self->proto_config($metaclass,$result,$errors); |
|
19
|
|
|
|
|
|
|
}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub proto_config { |
|
22
|
20
|
|
|
20
|
0
|
67
|
my ($self,$metaclass,$result,$errors) = @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Check if we have a config |
|
25
|
|
|
|
|
|
|
return ($result,$errors) |
|
26
|
20
|
100
|
|
|
|
163
|
unless defined $result->{config}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Read config |
|
29
|
4
|
|
|
|
|
12
|
my $config_file = $result->{config}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
4
|
100
|
|
|
|
151
|
unless (-e $config_file) { |
|
32
|
1
|
|
|
|
|
18
|
push(@{$errors}, |
|
|
1
|
|
|
|
|
24
|
|
|
33
|
|
|
|
|
|
|
$self->command_message( |
|
34
|
|
|
|
|
|
|
header => "Could not find config file '".$config_file."'", |
|
35
|
|
|
|
|
|
|
type => "error", |
|
36
|
|
|
|
|
|
|
), |
|
37
|
|
|
|
|
|
|
); |
|
38
|
1
|
|
|
|
|
7
|
return ($result,$errors); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
82
|
my $configs = Config::Any->load_files({ |
|
42
|
|
|
|
|
|
|
files => [ $config_file ], |
|
43
|
|
|
|
|
|
|
use_ext => 1, |
|
44
|
|
|
|
|
|
|
}); |
|
45
|
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
44653
|
my $command_name = $self->command_class_to_command($metaclass->name); |
|
47
|
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
15
|
my ($config_data) = values %{$configs->[0]}; |
|
|
3
|
|
|
|
|
18
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Merge |
|
51
|
3
|
|
50
|
|
|
23
|
$config_data->{global} ||= {}; |
|
52
|
3
|
|
100
|
|
|
33
|
$config_data->{$command_name} ||= {}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Set config data |
|
55
|
3
|
|
|
|
|
32
|
$result->{config} = $result->{config}; |
|
56
|
3
|
|
|
|
|
29
|
$result->{_config_data} = $config_data; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Lopp all attributes |
|
59
|
|
|
|
|
|
|
|
|
60
|
3
|
|
|
|
|
45
|
foreach my $attribute ($self->command_usage_attributes($metaclass,'all')) { |
|
61
|
14
|
|
|
|
|
93
|
my $attribute_name = $attribute->name; |
|
62
|
|
|
|
|
|
|
next |
|
63
|
14
|
100
|
100
|
|
|
100
|
if $attribute_name eq 'config' || $attribute_name eq 'help_flag'; |
|
64
|
|
|
|
|
|
|
$result->{$attribute_name} = $config_data->{global}{$attribute_name} |
|
65
|
8
|
100
|
|
|
|
37
|
if defined $config_data->{global}{$attribute_name}; |
|
66
|
|
|
|
|
|
|
$result->{$attribute_name} = $config_data->{$command_name}{$attribute_name} |
|
67
|
8
|
100
|
|
|
|
41
|
if defined $config_data->{$command_name}{$attribute_name}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
3
|
|
|
|
|
208
|
return ($result,$errors); |
|
71
|
|
|
|
|
|
|
}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |