line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Driver::Class; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
144
|
use Modern::Perl; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
204
|
|
4
|
18
|
|
|
18
|
|
3594
|
use Moose; |
|
18
|
|
|
|
|
131
|
|
|
18
|
|
|
|
|
149
|
|
5
|
18
|
|
|
18
|
|
134932
|
use namespace::autoclean; |
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
222
|
|
6
|
18
|
|
|
18
|
|
1863
|
use Kavorka '-all'; |
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
187
|
|
7
|
18
|
|
|
18
|
|
75221
|
use Data::Printer alias => 'pdump'; |
|
18
|
|
|
|
|
51
|
|
|
18
|
|
|
|
|
229
|
|
8
|
18
|
|
|
18
|
|
2036
|
use CLI::Driver::Option; |
|
18
|
|
|
|
|
62
|
|
|
18
|
|
|
|
|
2575
|
|
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
|
|
52543
|
method parse (HashRef :$href!) { |
|
18
|
50
|
33
|
18
|
|
148
|
|
|
18
|
50
|
|
18
|
|
2725
|
|
|
18
|
50
|
|
18
|
|
146
|
|
|
18
|
50
|
|
18
|
|
48
|
|
|
18
|
50
|
|
272
|
|
1044
|
|
|
18
|
|
|
|
|
125
|
|
|
18
|
|
|
|
|
52
|
|
|
18
|
|
|
|
|
184
|
|
|
18
|
|
|
|
|
1802
|
|
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
8131
|
|
|
18
|
|
|
|
|
157
|
|
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
4997
|
|
|
272
|
|
|
|
|
755
|
|
|
272
|
|
|
|
|
505
|
|
|
272
|
|
|
|
|
397
|
|
|
272
|
|
|
|
|
874
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
441
|
|
|
272
|
|
|
|
|
538
|
|
|
272
|
|
|
|
|
687
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
757
|
|
|
272
|
|
|
|
|
542
|
|
|
272
|
|
|
|
|
727
|
|
|
272
|
|
|
|
|
765
|
|
|
272
|
|
|
|
|
444
|
|
|
272
|
|
|
|
|
761
|
|
|
272
|
|
|
|
|
1742
|
|
|
272
|
|
|
|
|
781
|
|
|
272
|
|
|
|
|
609
|
|
|
272
|
|
|
|
|
403
|
|
|
272
|
|
|
|
|
687
|
|
|
272
|
|
|
|
|
412
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# self->name |
35
|
272
|
50
|
|
|
|
627
|
if ( !$href->{name} ) { |
36
|
0
|
|
|
|
|
0
|
$self->warn("failed to find class name"); |
37
|
0
|
|
|
|
|
0
|
return 0; # failed |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
272
|
|
|
|
|
8302
|
$self->name( $href->{name} ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# self->attr |
44
|
272
|
|
|
|
|
1089
|
my $attr = $self->_parse_attrs( href => $href ); |
45
|
272
|
50
|
|
|
|
712
|
if ( !$attr ) { |
46
|
0
|
|
|
|
|
0
|
return 0; # failed |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
272
|
|
|
|
|
8118
|
$self->attr($attr); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
272
|
|
|
|
|
915
|
return 1; # success |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
method find_req_attrs (Bool :$hard = 1, |
56
|
18
|
50
|
33
|
18
|
|
79001
|
Bool :$soft = 1) { |
|
18
|
50
|
33
|
18
|
|
61
|
|
|
18
|
50
|
|
18
|
|
2547
|
|
|
18
|
50
|
|
18
|
|
137
|
|
|
18
|
50
|
|
18
|
|
43
|
|
|
18
|
50
|
|
18
|
|
936
|
|
|
18
|
50
|
|
29
|
|
119
|
|
|
18
|
|
|
|
|
46
|
|
|
18
|
|
|
|
|
127
|
|
|
18
|
|
|
|
|
1778
|
|
|
18
|
|
|
|
|
55
|
|
|
18
|
|
|
|
|
7077
|
|
|
18
|
|
|
|
|
144
|
|
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
2411
|
|
|
18
|
|
|
|
|
138
|
|
|
18
|
|
|
|
|
54
|
|
|
18
|
|
|
|
|
5723
|
|
|
29
|
|
|
|
|
145
|
|
|
29
|
|
|
|
|
84
|
|
|
29
|
|
|
|
|
57
|
|
|
29
|
|
|
|
|
163
|
|
|
0
|
|
|
|
|
0
|
|
|
29
|
|
|
|
|
63
|
|
|
29
|
|
|
|
|
87
|
|
|
29
|
|
|
|
|
122
|
|
|
0
|
|
|
|
|
0
|
|
|
29
|
|
|
|
|
119
|
|
|
58
|
|
|
|
|
129
|
|
|
58
|
|
|
|
|
244
|
|
|
58
|
|
|
|
|
163
|
|
|
29
|
|
|
|
|
70
|
|
|
29
|
|
|
|
|
142
|
|
|
29
|
|
|
|
|
312
|
|
|
29
|
|
|
|
|
137
|
|
|
29
|
|
|
|
|
61
|
|
|
29
|
|
|
|
|
849
|
|
|
29
|
|
|
|
|
132
|
|
|
29
|
|
|
|
|
55
|
|
|
29
|
|
|
|
|
104
|
|
|
29
|
|
|
|
|
60
|
|
57
|
|
|
|
|
|
|
|
58
|
29
|
|
|
|
|
62
|
my @req; |
59
|
29
|
|
|
|
|
59
|
my @opts = @{ $self->attr }; |
|
29
|
|
|
|
|
1081
|
|
60
|
|
|
|
|
|
|
|
61
|
29
|
|
|
|
|
93
|
foreach my $opt (@opts) { |
62
|
|
|
|
|
|
|
|
63
|
27
|
100
|
|
|
|
132
|
if ( $opt->is_required ) { |
64
|
|
|
|
|
|
|
|
65
|
16
|
50
|
33
|
|
|
141
|
if ( $hard and $opt->is_hard ) { |
|
|
100
|
66
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
push @req, $opt; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif ( $soft and $opt->is_soft ) { |
69
|
2
|
|
|
|
|
7
|
push @req, $opt; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
|
|
|
|
|
|
# drop it |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
29
|
|
|
|
|
207
|
return @req; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
18
|
50
|
|
18
|
|
24176
|
method get_signature { |
|
18
|
|
|
31
|
|
105
|
|
|
18
|
|
|
|
|
7452
|
|
|
31
|
|
|
|
|
119
|
|
|
31
|
|
|
|
|
61
|
|
81
|
|
|
|
|
|
|
|
82
|
31
|
|
|
|
|
65
|
my %return; |
83
|
31
|
|
|
|
|
96
|
my @opts = @{ $self->attr }; |
|
31
|
|
|
|
|
903
|
|
84
|
|
|
|
|
|
|
|
85
|
31
|
|
|
|
|
102
|
foreach my $opt (@opts) { |
86
|
|
|
|
|
|
|
|
87
|
29
|
|
|
|
|
119
|
my %sig = $opt->get_signature; |
88
|
29
|
|
|
|
|
83
|
my @keys = keys %sig; |
89
|
|
|
|
|
|
|
|
90
|
29
|
100
|
100
|
|
|
150
|
if ( @keys == 1 ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# happy path |
92
|
21
|
|
|
|
|
78
|
my $key = shift @keys; |
93
|
21
|
|
|
|
|
83
|
$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
|
|
|
|
|
345
|
confess $msg; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
29
|
|
|
|
|
159
|
return %return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
######################################################## |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |