line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Driver::Class; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
144
|
use Modern::Perl; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
215
|
|
4
|
18
|
|
|
18
|
|
4439
|
use Moose; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
149
|
|
5
|
18
|
|
|
18
|
|
129535
|
use namespace::autoclean; |
|
18
|
|
|
|
|
46
|
|
|
18
|
|
|
|
|
220
|
|
6
|
18
|
|
|
18
|
|
1795
|
use Kavorka '-all'; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
181
|
|
7
|
18
|
|
|
18
|
|
72546
|
use Data::Printer alias => 'pdump'; |
|
18
|
|
|
|
|
50
|
|
|
18
|
|
|
|
|
236
|
|
8
|
18
|
|
|
18
|
|
1967
|
use CLI::Driver::Option; |
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
2384
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with |
11
|
|
|
|
|
|
|
'CLI::Driver::CommonRole', |
12
|
|
|
|
|
|
|
'CLI::Driver::ArgParserRole'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
############################### |
15
|
|
|
|
|
|
|
###### PUBLIC ATTRIBUTES ###### |
16
|
|
|
|
|
|
|
############################### |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has name => ( is => 'rw' ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has attr => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'ArrayRef[CLI::Driver::Option]', |
23
|
|
|
|
|
|
|
default => sub { [] } |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'use_argv_map' => ( is => 'rw', isa => 'Bool' ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################ |
29
|
|
|
|
|
|
|
###### PUBLIC METHODS ###### |
30
|
|
|
|
|
|
|
############################ |
31
|
|
|
|
|
|
|
|
32
|
18
|
50
|
33
|
18
|
|
51203
|
method parse (HashRef :$href!) { |
|
18
|
50
|
33
|
18
|
|
65
|
|
|
18
|
50
|
|
18
|
|
2463
|
|
|
18
|
50
|
|
18
|
|
142
|
|
|
18
|
50
|
|
18
|
|
36
|
|
|
18
|
50
|
|
272
|
|
1026
|
|
|
18
|
|
|
|
|
123
|
|
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
173
|
|
|
18
|
|
|
|
|
1728
|
|
|
18
|
|
|
|
|
52
|
|
|
18
|
|
|
|
|
7507
|
|
|
18
|
|
|
|
|
142
|
|
|
18
|
|
|
|
|
50
|
|
|
18
|
|
|
|
|
4723
|
|
|
272
|
|
|
|
|
704
|
|
|
272
|
|
|
|
|
508
|
|
|
272
|
|
|
|
|
386
|
|
|
272
|
|
|
|
|
882
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
436
|
|
|
272
|
|
|
|
|
529
|
|
|
272
|
|
|
|
|
713
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
799
|
|
|
272
|
|
|
|
|
559
|
|
|
272
|
|
|
|
|
736
|
|
|
272
|
|
|
|
|
721
|
|
|
272
|
|
|
|
|
425
|
|
|
272
|
|
|
|
|
724
|
|
|
272
|
|
|
|
|
1706
|
|
|
272
|
|
|
|
|
785
|
|
|
272
|
|
|
|
|
639
|
|
|
272
|
|
|
|
|
401
|
|
|
272
|
|
|
|
|
769
|
|
|
272
|
|
|
|
|
406
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# self->name |
35
|
272
|
50
|
|
|
|
663
|
if ( !$href->{name} ) { |
36
|
0
|
|
|
|
|
0
|
$self->warn("failed to find class name"); |
37
|
0
|
|
|
|
|
0
|
return 0; # failed |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
272
|
|
|
|
|
8235
|
$self->name( $href->{name} ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# self->attr |
44
|
272
|
|
|
|
|
1108
|
my $attr = $self->_parse_attrs( href => $href ); |
45
|
272
|
50
|
|
|
|
689
|
if ( !$attr ) { |
46
|
0
|
|
|
|
|
0
|
return 0; # failed |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
272
|
|
|
|
|
7994
|
$self->attr($attr); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
272
|
|
|
|
|
929
|
return 1; # success |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
method find_req_attrs (Bool :$hard = 1, |
56
|
18
|
50
|
33
|
18
|
|
75372
|
Bool :$soft = 1) { |
|
18
|
50
|
33
|
18
|
|
51
|
|
|
18
|
50
|
|
18
|
|
2397
|
|
|
18
|
50
|
|
18
|
|
139
|
|
|
18
|
50
|
|
18
|
|
55
|
|
|
18
|
50
|
|
18
|
|
907
|
|
|
18
|
50
|
|
29
|
|
123
|
|
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
128
|
|
|
18
|
|
|
|
|
1573
|
|
|
18
|
|
|
|
|
53
|
|
|
18
|
|
|
|
|
6802
|
|
|
18
|
|
|
|
|
134
|
|
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
2398
|
|
|
18
|
|
|
|
|
133
|
|
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
5294
|
|
|
29
|
|
|
|
|
139
|
|
|
29
|
|
|
|
|
75
|
|
|
29
|
|
|
|
|
61
|
|
|
29
|
|
|
|
|
162
|
|
|
0
|
|
|
|
|
0
|
|
|
29
|
|
|
|
|
67
|
|
|
29
|
|
|
|
|
87
|
|
|
29
|
|
|
|
|
113
|
|
|
0
|
|
|
|
|
0
|
|
|
29
|
|
|
|
|
124
|
|
|
58
|
|
|
|
|
122
|
|
|
58
|
|
|
|
|
171
|
|
|
58
|
|
|
|
|
155
|
|
|
29
|
|
|
|
|
60
|
|
|
29
|
|
|
|
|
140
|
|
|
29
|
|
|
|
|
304
|
|
|
29
|
|
|
|
|
169
|
|
|
29
|
|
|
|
|
64
|
|
|
29
|
|
|
|
|
832
|
|
|
29
|
|
|
|
|
115
|
|
|
29
|
|
|
|
|
64
|
|
|
29
|
|
|
|
|
108
|
|
|
29
|
|
|
|
|
59
|
|
57
|
|
|
|
|
|
|
|
58
|
29
|
|
|
|
|
61
|
my @req; |
59
|
29
|
|
|
|
|
60
|
my @opts = @{ $self->attr }; |
|
29
|
|
|
|
|
924
|
|
60
|
|
|
|
|
|
|
|
61
|
29
|
|
|
|
|
87
|
foreach my $opt (@opts) { |
62
|
|
|
|
|
|
|
|
63
|
27
|
100
|
|
|
|
109
|
if ( $opt->is_required ) { |
64
|
|
|
|
|
|
|
|
65
|
16
|
50
|
33
|
|
|
136
|
if ( $hard and $opt->is_hard ) { |
|
|
100
|
66
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
push @req, $opt; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif ( $soft and $opt->is_soft ) { |
69
|
2
|
|
|
|
|
6
|
push @req, $opt; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
|
|
|
|
|
|
# drop it |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
29
|
|
|
|
|
142
|
return @req; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
18
|
50
|
|
18
|
|
23420
|
method get_signature { |
|
18
|
|
|
31
|
|
46
|
|
|
18
|
|
|
|
|
7073
|
|
|
31
|
|
|
|
|
122
|
|
|
31
|
|
|
|
|
55
|
|
81
|
|
|
|
|
|
|
|
82
|
31
|
|
|
|
|
63
|
my %return; |
83
|
31
|
|
|
|
|
62
|
my @opts = @{ $self->attr }; |
|
31
|
|
|
|
|
948
|
|
84
|
|
|
|
|
|
|
|
85
|
31
|
|
|
|
|
96
|
foreach my $opt (@opts) { |
86
|
|
|
|
|
|
|
|
87
|
29
|
|
|
|
|
137
|
my %sig = $opt->get_signature; |
88
|
29
|
|
|
|
|
96
|
my @keys = keys %sig; |
89
|
|
|
|
|
|
|
|
90
|
29
|
100
|
100
|
|
|
134
|
if ( @keys == 1 ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# happy path |
92
|
21
|
|
|
|
|
49
|
my $key = shift @keys; |
93
|
21
|
|
|
|
|
78
|
$return{$key} = $sig{$key}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( @keys > 1 ) { |
96
|
0
|
|
|
|
|
0
|
confess "should not get here"; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
elsif ( $opt->is_required and $opt->is_hard ) { |
99
|
2
|
|
|
|
|
54
|
my $msg = sprintf( "missing args: -%s <%s>", |
100
|
|
|
|
|
|
|
$opt->cli_arg, $opt->method_arg ); |
101
|
2
|
|
|
|
|
378
|
confess $msg; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
29
|
|
|
|
|
164
|
return %return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
######################################################## |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |