line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::Driver::Method; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
147
|
use Modern::Perl; |
|
18
|
|
|
|
|
46
|
|
|
18
|
|
|
|
|
191
|
|
4
|
18
|
|
|
18
|
|
3571
|
use Moose; |
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
134
|
|
5
|
18
|
|
|
18
|
|
124715
|
use namespace::autoclean; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
184
|
|
6
|
18
|
|
|
18
|
|
1665
|
use Kavorka '-all'; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
154
|
|
7
|
18
|
|
|
18
|
|
74079
|
use Data::Printer alias => 'pdump'; |
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
226
|
|
8
|
18
|
|
|
18
|
|
1883
|
use CLI::Driver::Option; |
|
18
|
|
|
|
|
82
|
|
|
18
|
|
|
|
|
2371
|
|
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
|
|
50284
|
method parse (HashRef :$href!) { |
|
18
|
50
|
33
|
18
|
|
49
|
|
|
18
|
50
|
|
18
|
|
2756
|
|
|
18
|
50
|
|
18
|
|
173
|
|
|
18
|
50
|
|
18
|
|
39
|
|
|
18
|
50
|
|
272
|
|
1049
|
|
|
18
|
|
|
|
|
136
|
|
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
179
|
|
|
18
|
|
|
|
|
1747
|
|
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
7125
|
|
|
18
|
|
|
|
|
140
|
|
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
4794
|
|
|
272
|
|
|
|
|
748
|
|
|
272
|
|
|
|
|
500
|
|
|
272
|
|
|
|
|
416
|
|
|
272
|
|
|
|
|
865
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
443
|
|
|
272
|
|
|
|
|
516
|
|
|
272
|
|
|
|
|
698
|
|
|
0
|
|
|
|
|
0
|
|
|
272
|
|
|
|
|
701
|
|
|
272
|
|
|
|
|
494
|
|
|
272
|
|
|
|
|
807
|
|
|
272
|
|
|
|
|
776
|
|
|
272
|
|
|
|
|
429
|
|
|
272
|
|
|
|
|
717
|
|
|
272
|
|
|
|
|
1521
|
|
|
272
|
|
|
|
|
825
|
|
|
272
|
|
|
|
|
633
|
|
|
272
|
|
|
|
|
376
|
|
|
272
|
|
|
|
|
660
|
|
|
272
|
|
|
|
|
390
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# self->name |
35
|
272
|
50
|
|
|
|
649
|
if ( !$href->{name} ) { |
36
|
0
|
|
|
|
|
0
|
$self->warn("failed to find method name"); |
37
|
0
|
|
|
|
|
0
|
return 0; # failed |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
272
|
|
|
|
|
7873
|
$self->name( $href->{name} ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# self->args |
44
|
272
|
|
|
|
|
1098
|
my $args = $self->_parse_args( href => $href ); |
45
|
272
|
50
|
|
|
|
697
|
if ( !$args ) { |
46
|
0
|
|
|
|
|
0
|
return 0; # failed |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
272
|
|
|
|
|
8236
|
$self->args($args); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
272
|
|
|
|
|
925
|
return 1; # success |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
18
|
50
|
|
18
|
|
22796
|
method get_signature { |
|
18
|
|
|
28
|
|
49
|
|
|
18
|
|
|
|
|
7117
|
|
|
28
|
|
|
|
|
148
|
|
|
28
|
|
|
|
|
60
|
|
56
|
|
|
|
|
|
|
|
57
|
28
|
|
|
|
|
59
|
my %return; |
58
|
28
|
|
|
|
|
73
|
my @opts = @{ $self->args }; |
|
28
|
|
|
|
|
748
|
|
59
|
|
|
|
|
|
|
|
60
|
28
|
|
|
|
|
76
|
foreach my $opt (@opts) { |
61
|
|
|
|
|
|
|
|
62
|
39
|
|
|
|
|
163
|
my %sig = $opt->get_signature; |
63
|
39
|
|
|
|
|
137
|
my @keys = keys %sig; |
64
|
|
|
|
|
|
|
|
65
|
39
|
100
|
100
|
|
|
434
|
if ( @keys == 1 ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
66
|
28
|
|
|
|
|
79
|
my $key = shift @keys; |
67
|
28
|
|
|
|
|
108
|
$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
|
|
|
|
|
124
|
my $msg = sprintf( "missing args: -%s <%s>", |
74
|
|
|
|
|
|
|
$opt->cli_arg, $opt->method_arg ); |
75
|
3
|
|
|
|
|
701
|
confess $msg; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
25
|
|
|
|
|
145
|
return %return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |