line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Driver::Method; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
134
|
use Modern::Perl; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
178
|
|
4
|
18
|
|
|
18
|
|
3156
|
use Moose; |
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
128
|
|
5
|
18
|
|
|
18
|
|
115394
|
use namespace::autoclean; |
|
18
|
|
|
|
|
58
|
|
|
18
|
|
|
|
|
189
|
|
6
|
18
|
|
|
18
|
|
1575
|
use Kavorka '-all'; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
182
|
|
7
|
18
|
|
|
18
|
|
67154
|
use Data::Printer alias => 'pdump'; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
193
|
|
8
|
18
|
|
|
18
|
|
1783
|
use CLI::Driver::Option; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
2094
|
|
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 args => ( |
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
|
|
47991
|
method parse (HashRef :$href!) { |
|
18
|
50
|
33
|
18
|
|
44
|
|
|
18
|
50
|
|
18
|
|
2606
|
|
|
18
|
50
|
|
18
|
|
169
|
|
|
18
|
50
|
|
18
|
|
41
|
|
|
18
|
50
|
|
272
|
|
952
|
|
|
18
|
|
|
|
|
113
|
|
|
18
|
|
|
|
|
61
|
|
|
18
|
|
|
|
|
163
|
|
|
18
|
|
|
|
|
1721
|
|
|
18
|
|
|
|
|
50
|
|
|
18
|
|
|
|
|
6520
|
|
|
18
|
|
|
|
|
126
|
|
|
18
|
|
|
|
|
34
|
|
|
18
|
|
|
|
|
4187
|
|
|
272
|
|
|
|
|
683
|
|
|
272
|
|
|
|
|
459
|
|
|
272
|
|
|
|
|
380
|
|
|
272
|
|
|
|
|
813
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
412
|
|
|
272
|
|
|
|
|
488
|
|
|
272
|
|
|
|
|
619
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
600
|
|
|
272
|
|
|
|
|
485
|
|
|
272
|
|
|
|
|
678
|
|
|
272
|
|
|
|
|
656
|
|
|
272
|
|
|
|
|
421
|
|
|
272
|
|
|
|
|
668
|
|
|
272
|
|
|
|
|
1381
|
|
|
272
|
|
|
|
|
702
|
|
|
272
|
|
|
|
|
615
|
|
|
272
|
|
|
|
|
366
|
|
|
272
|
|
|
|
|
571
|
|
|
272
|
|
|
|
|
383
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# self->name |
35
|
272
|
50
|
|
|
|
610
|
if ( !$href->{name} ) { |
36
|
0
|
|
|
|
|
0
|
$self->warn("failed to find method name"); |
37
|
0
|
|
|
|
|
0
|
return 0; # failed |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
272
|
|
|
|
|
7226
|
$self->name( $href->{name} ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# self->args |
44
|
272
|
|
|
|
|
947
|
my $args = $self->_parse_args( href => $href ); |
45
|
272
|
50
|
|
|
|
679
|
if ( !$args ) { |
46
|
0
|
|
|
|
|
0
|
return 0; # failed |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
272
|
|
|
|
|
7880
|
$self->args($args); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
272
|
|
|
|
|
903
|
return 1; # success |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
18
|
50
|
|
18
|
|
19963
|
method get_signature { |
|
18
|
|
|
28
|
|
41
|
|
|
18
|
|
|
|
|
6393
|
|
|
28
|
|
|
|
|
150
|
|
|
28
|
|
|
|
|
54
|
|
56
|
|
|
|
|
|
|
|
57
|
28
|
|
|
|
|
84
|
my %return; |
58
|
28
|
|
|
|
|
60
|
my @opts = @{ $self->args }; |
|
28
|
|
|
|
|
739
|
|
59
|
|
|
|
|
|
|
|
60
|
28
|
|
|
|
|
90
|
foreach my $opt (@opts) { |
61
|
|
|
|
|
|
|
|
62
|
40
|
|
|
|
|
169
|
my %sig = $opt->get_signature; |
63
|
40
|
|
|
|
|
108
|
my @keys = keys %sig; |
64
|
|
|
|
|
|
|
|
65
|
40
|
100
|
100
|
|
|
458
|
if ( @keys == 1 ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
66
|
28
|
|
|
|
|
56
|
my $key = shift @keys; |
67
|
28
|
|
|
|
|
109
|
$return{$key} = $sig{$key}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( @keys > 1 ) { |
70
|
0
|
|
|
|
|
0
|
confess "should not get here"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
elsif ( $opt->required and $opt->is_hard ) { |
73
|
3
|
|
|
|
|
87
|
my $msg = sprintf( "missing args: -%s <%s>", |
74
|
|
|
|
|
|
|
$opt->cli_arg, $opt->method_arg ); |
75
|
3
|
|
|
|
|
639
|
confess $msg; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
25
|
|
|
|
|
142
|
return %return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |