line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Driver::Class; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
131
|
use Modern::Perl; |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
182
|
|
4
|
18
|
|
|
18
|
|
3207
|
use Moose; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
133
|
|
5
|
18
|
|
|
18
|
|
117955
|
use namespace::autoclean; |
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
193
|
|
6
|
18
|
|
|
18
|
|
1585
|
use Kavorka '-all'; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
157
|
|
7
|
18
|
|
|
18
|
|
66278
|
use Data::Printer alias => 'pdump'; |
|
18
|
|
|
|
|
46
|
|
|
18
|
|
|
|
|
201
|
|
8
|
18
|
|
|
18
|
|
1761
|
use CLI::Driver::Option; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
2215
|
|
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
|
|
47608
|
method parse (HashRef :$href!) { |
|
18
|
50
|
33
|
18
|
|
40
|
|
|
18
|
50
|
|
18
|
|
2276
|
|
|
18
|
50
|
|
18
|
|
144
|
|
|
18
|
50
|
|
18
|
|
40
|
|
|
18
|
50
|
|
272
|
|
934
|
|
|
18
|
|
|
|
|
107
|
|
|
18
|
|
|
|
|
35
|
|
|
18
|
|
|
|
|
158
|
|
|
18
|
|
|
|
|
1656
|
|
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
6954
|
|
|
18
|
|
|
|
|
133
|
|
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
4258
|
|
|
272
|
|
|
|
|
684
|
|
|
272
|
|
|
|
|
491
|
|
|
272
|
|
|
|
|
382
|
|
|
272
|
|
|
|
|
800
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
407
|
|
|
272
|
|
|
|
|
538
|
|
|
272
|
|
|
|
|
623
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
677
|
|
|
272
|
|
|
|
|
493
|
|
|
272
|
|
|
|
|
689
|
|
|
272
|
|
|
|
|
688
|
|
|
272
|
|
|
|
|
373
|
|
|
272
|
|
|
|
|
704
|
|
|
272
|
|
|
|
|
1616
|
|
|
272
|
|
|
|
|
707
|
|
|
272
|
|
|
|
|
618
|
|
|
272
|
|
|
|
|
370
|
|
|
272
|
|
|
|
|
721
|
|
|
272
|
|
|
|
|
361
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# self->name |
35
|
272
|
50
|
|
|
|
608
|
if ( !$href->{name} ) { |
36
|
0
|
|
|
|
|
0
|
$self->warn("failed to find class name"); |
37
|
0
|
|
|
|
|
0
|
return 0; # failed |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
272
|
|
|
|
|
7342
|
$self->name( $href->{name} ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# self->attr |
44
|
272
|
|
|
|
|
983
|
my $attr = $self->_parse_attrs( href => $href ); |
45
|
272
|
50
|
|
|
|
649
|
if ( !$attr ) { |
46
|
0
|
|
|
|
|
0
|
return 0; # failed |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
272
|
|
|
|
|
7223
|
$self->attr($attr); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
272
|
|
|
|
|
841
|
return 1; # success |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
method find_req_attrs (Bool :$hard = 1, |
56
|
18
|
50
|
33
|
18
|
|
66369
|
Bool :$soft = 1) { |
|
18
|
50
|
33
|
18
|
|
43
|
|
|
18
|
50
|
|
18
|
|
2043
|
|
|
18
|
50
|
|
18
|
|
119
|
|
|
18
|
50
|
|
18
|
|
44
|
|
|
18
|
50
|
|
18
|
|
815
|
|
|
18
|
50
|
|
29
|
|
109
|
|
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
82
|
|
|
18
|
|
|
|
|
1352
|
|
|
18
|
|
|
|
|
53
|
|
|
18
|
|
|
|
|
6180
|
|
|
18
|
|
|
|
|
129
|
|
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
2105
|
|
|
18
|
|
|
|
|
120
|
|
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
4902
|
|
|
29
|
|
|
|
|
140
|
|
|
29
|
|
|
|
|
76
|
|
|
29
|
|
|
|
|
71
|
|
|
29
|
|
|
|
|
168
|
|
|
0
|
|
|
|
|
0
|
|
|
29
|
|
|
|
|
75
|
|
|
29
|
|
|
|
|
91
|
|
|
29
|
|
|
|
|
179
|
|
|
0
|
|
|
|
|
0
|
|
|
29
|
|
|
|
|
124
|
|
|
58
|
|
|
|
|
126
|
|
|
58
|
|
|
|
|
180
|
|
|
58
|
|
|
|
|
145
|
|
|
29
|
|
|
|
|
65
|
|
|
29
|
|
|
|
|
165
|
|
|
29
|
|
|
|
|
336
|
|
|
29
|
|
|
|
|
140
|
|
|
29
|
|
|
|
|
72
|
|
|
29
|
|
|
|
|
767
|
|
|
29
|
|
|
|
|
120
|
|
|
29
|
|
|
|
|
59
|
|
|
29
|
|
|
|
|
103
|
|
|
29
|
|
|
|
|
59
|
|
57
|
|
|
|
|
|
|
|
58
|
29
|
|
|
|
|
61
|
my @req; |
59
|
29
|
|
|
|
|
60
|
my @opts = @{ $self->attr }; |
|
29
|
|
|
|
|
1014
|
|
60
|
|
|
|
|
|
|
|
61
|
29
|
|
|
|
|
91
|
foreach my $opt (@opts) { |
62
|
|
|
|
|
|
|
|
63
|
27
|
100
|
|
|
|
128
|
if ( $opt->is_required ) { |
64
|
|
|
|
|
|
|
|
65
|
16
|
50
|
33
|
|
|
144
|
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
|
|
|
|
|
137
|
return @req; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
18
|
50
|
|
18
|
|
19996
|
method get_signature { |
|
18
|
|
|
31
|
|
42
|
|
|
18
|
|
|
|
|
6387
|
|
|
31
|
|
|
|
|
123
|
|
|
31
|
|
|
|
|
60
|
|
81
|
|
|
|
|
|
|
|
82
|
31
|
|
|
|
|
66
|
my %return; |
83
|
31
|
|
|
|
|
59
|
my @opts = @{ $self->attr }; |
|
31
|
|
|
|
|
746
|
|
84
|
|
|
|
|
|
|
|
85
|
31
|
|
|
|
|
94
|
foreach my $opt (@opts) { |
86
|
|
|
|
|
|
|
|
87
|
30
|
|
|
|
|
154
|
my %sig = $opt->get_signature; |
88
|
30
|
|
|
|
|
124
|
my @keys = keys %sig; |
89
|
|
|
|
|
|
|
|
90
|
30
|
100
|
100
|
|
|
141
|
if ( @keys == 1 ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# happy path |
92
|
21
|
|
|
|
|
47
|
my $key = shift @keys; |
93
|
21
|
|
|
|
|
82
|
$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
|
|
|
|
|
50
|
my $msg = sprintf( "missing args: -%s <%s>", |
100
|
|
|
|
|
|
|
$opt->cli_arg, $opt->method_arg ); |
101
|
2
|
|
|
|
|
367
|
confess $msg; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
29
|
|
|
|
|
142
|
return %return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
######################################################## |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |