line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Plugin::Depends::Meta::Class; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
2359
|
use Moose::Role; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
26
|
|
6
|
3
|
|
|
3
|
|
16746
|
use namespace::autoclean; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
26
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
around 'command_check_attributes' => sub { |
9
|
|
|
|
|
|
|
my ($orig, $self, $command_meta, $errors, $params) = @_; |
10
|
|
|
|
|
|
|
$command_meta ||= $self; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
ATTR: |
13
|
|
|
|
|
|
|
foreach my $attribute ( $self->command_usage_attributes($command_meta, 'all') ) { |
14
|
|
|
|
|
|
|
next ATTR |
15
|
|
|
|
|
|
|
unless defined $params->{ $attribute->cmd_name_primary }; |
16
|
|
|
|
|
|
|
next ATTR |
17
|
|
|
|
|
|
|
unless $attribute->can('depends') |
18
|
|
|
|
|
|
|
&& ref($attribute->depends) eq 'ARRAY' |
19
|
|
|
|
|
|
|
&& scalar @{ $attribute->depends } > 0; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
OPT: |
22
|
|
|
|
|
|
|
foreach my $required_option ( @{ $attribute->depends } ) { |
23
|
|
|
|
|
|
|
next OPT |
24
|
|
|
|
|
|
|
if defined $params->{$required_option}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $error_msg = "Option " |
27
|
|
|
|
|
|
|
. "'" . $attribute->cmd_name_primary . "'" |
28
|
|
|
|
|
|
|
. " requires '$required_option' to be defined"; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
push @$errors, |
31
|
|
|
|
|
|
|
$self->command_message( |
32
|
|
|
|
|
|
|
header => $error_msg, |
33
|
|
|
|
|
|
|
type => 'error', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $self->$orig($command_meta, $errors, $params); |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |