App/Plugin/Term/Meta/Class.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 77 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 # ============================================================================
2 package MooseX::App::Plugin::Term::Meta::Class;
3 # ============================================================================
4  
5 use 5.010;
6 use utf8;
7  
8 use namespace::autoclean;
9 use Moose::Role;
10  
11 use IO::Interactive qw(is_interactive);
12  
13 around 'command_check_attributes' => sub {
14 my ($orig,$self,$command_meta,$errors,$params) = @_;
15  
16 $command_meta ||= $self;
17  
18 if (scalar @{$errors} == 0
19 && is_interactive()) {
20  
21 my $prompt = 1;
22 foreach my $attribute ($self->command_usage_attributes($command_meta,'all')) {
23 if ($attribute->is_required
24 && ! exists $params->{$attribute->name}
25 && (! $attribute->can('cmd_term') || $attribute->cmd_term == 0 )) {
26 $prompt = 0;
27 }
28 }
29  
30 if ($prompt) {
31 foreach my $attribute ($self->command_usage_attributes($command_meta,'all')) {
32 next
33 unless $attribute->can('cmd_term')
34 && $attribute->cmd_term;
35  
36 if (! defined $params->{$attribute->name}) {
37 my $return = $attribute->cmd_term_read();
38 $params->{$attribute->name} = $return
39 if defined $return;
40 }
41 }
42  
43 }
44 }
45  
46 return $self->$orig($command_meta,$errors,$params);
47 };
48  
49 1;