line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Driver::Method; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
153
|
use Modern::Perl; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
193
|
|
4
|
18
|
|
|
18
|
|
3593
|
use Moose; |
|
18
|
|
|
|
|
50
|
|
|
18
|
|
|
|
|
145
|
|
5
|
18
|
|
|
18
|
|
132025
|
use namespace::autoclean; |
|
18
|
|
|
|
|
59
|
|
|
18
|
|
|
|
|
230
|
|
6
|
18
|
|
|
18
|
|
1807
|
use Kavorka '-all'; |
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
206
|
|
7
|
18
|
|
|
18
|
|
76222
|
use Data::Printer alias => 'pdump'; |
|
18
|
|
|
|
|
56
|
|
|
18
|
|
|
|
|
223
|
|
8
|
18
|
|
|
18
|
|
1998
|
use CLI::Driver::Option; |
|
18
|
|
|
|
|
85
|
|
|
18
|
|
|
|
|
2409
|
|
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
|
|
54245
|
method parse (HashRef :$href!) { |
|
18
|
50
|
33
|
18
|
|
52
|
|
|
18
|
50
|
|
18
|
|
3007
|
|
|
18
|
50
|
|
18
|
|
168
|
|
|
18
|
50
|
|
18
|
|
50
|
|
|
18
|
50
|
|
272
|
|
1086
|
|
|
18
|
|
|
|
|
138
|
|
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
184
|
|
|
18
|
|
|
|
|
1896
|
|
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
7407
|
|
|
18
|
|
|
|
|
143
|
|
|
18
|
|
|
|
|
47
|
|
|
18
|
|
|
|
|
4968
|
|
|
272
|
|
|
|
|
712
|
|
|
272
|
|
|
|
|
480
|
|
|
272
|
|
|
|
|
395
|
|
|
272
|
|
|
|
|
867
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
463
|
|
|
272
|
|
|
|
|
540
|
|
|
272
|
|
|
|
|
687
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
630
|
|
|
272
|
|
|
|
|
530
|
|
|
272
|
|
|
|
|
682
|
|
|
272
|
|
|
|
|
710
|
|
|
272
|
|
|
|
|
501
|
|
|
272
|
|
|
|
|
745
|
|
|
272
|
|
|
|
|
1533
|
|
|
272
|
|
|
|
|
773
|
|
|
272
|
|
|
|
|
629
|
|
|
272
|
|
|
|
|
382
|
|
|
272
|
|
|
|
|
697
|
|
|
272
|
|
|
|
|
390
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# self->name |
35
|
272
|
50
|
|
|
|
632
|
if ( !$href->{name} ) { |
36
|
0
|
|
|
|
|
0
|
$self->warn("failed to find method name"); |
37
|
0
|
|
|
|
|
0
|
return 0; # failed |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
272
|
|
|
|
|
7977
|
$self->name( $href->{name} ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# self->args |
44
|
272
|
|
|
|
|
1006
|
my $args = $self->_parse_args( href => $href ); |
45
|
272
|
50
|
|
|
|
707
|
if ( !$args ) { |
46
|
0
|
|
|
|
|
0
|
return 0; # failed |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
272
|
|
|
|
|
8601
|
$self->args($args); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
272
|
|
|
|
|
959
|
return 1; # success |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
18
|
50
|
|
18
|
|
23515
|
method get_signature { |
|
18
|
|
|
28
|
|
56
|
|
|
18
|
|
|
|
|
7279
|
|
|
28
|
|
|
|
|
138
|
|
|
28
|
|
|
|
|
53
|
|
56
|
|
|
|
|
|
|
|
57
|
28
|
|
|
|
|
67
|
my %return; |
58
|
28
|
|
|
|
|
94
|
my @opts = @{ $self->args }; |
|
28
|
|
|
|
|
767
|
|
59
|
|
|
|
|
|
|
|
60
|
28
|
|
|
|
|
84
|
foreach my $opt (@opts) { |
61
|
|
|
|
|
|
|
|
62
|
39
|
|
|
|
|
153
|
my %sig = $opt->get_signature; |
63
|
39
|
|
|
|
|
171
|
my @keys = keys %sig; |
64
|
|
|
|
|
|
|
|
65
|
39
|
100
|
100
|
|
|
443
|
if ( @keys == 1 ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
66
|
28
|
|
|
|
|
55
|
my $key = shift @keys; |
67
|
28
|
|
|
|
|
111
|
$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
|
|
|
|
|
97
|
my $msg = sprintf( "missing args: -%s <%s>", |
74
|
|
|
|
|
|
|
$opt->cli_arg, $opt->method_arg ); |
75
|
3
|
|
|
|
|
692
|
confess $msg; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
25
|
|
|
|
|
143
|
return %return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |