line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Getopt::ArgParse::ActionStore; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
943
|
use strict; |
|
20
|
|
|
|
|
24
|
|
|
20
|
|
|
|
|
678
|
|
4
|
20
|
|
|
20
|
|
97
|
use warnings; |
|
20
|
|
|
|
|
52
|
|
|
20
|
|
|
|
|
496
|
|
5
|
20
|
|
|
20
|
|
78
|
use Carp; |
|
20
|
|
|
|
|
22
|
|
|
20
|
|
|
|
|
1232
|
|
6
|
|
|
|
|
|
|
|
7
|
20
|
|
|
20
|
|
91
|
use Getopt::ArgParse::Parser; |
|
20
|
|
|
|
|
21
|
|
|
20
|
|
|
|
|
3477
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub apply { |
10
|
152
|
|
|
152
|
0
|
841
|
my $self = shift; |
11
|
|
|
|
|
|
|
|
12
|
152
|
|
|
|
|
160
|
my ($spec, $namespace, $values) = @_; |
13
|
152
|
|
50
|
|
|
266
|
$values ||= []; |
14
|
|
|
|
|
|
|
|
15
|
152
|
100
|
|
|
|
256
|
return sprintf( |
16
|
|
|
|
|
|
|
'%s can only have one value', |
17
|
|
|
|
|
|
|
$spec->{dest}, |
18
|
|
|
|
|
|
|
) if @$values > 1; |
19
|
|
|
|
|
|
|
|
20
|
151
|
100
|
|
|
|
255
|
if ($spec->{type} == Getopt::ArgParse::Parser::TYPE_BOOL) { |
21
|
|
|
|
|
|
|
# If there is default true or false |
22
|
85
|
|
100
|
|
|
345
|
my $default = $spec->{default} || [ 0 ]; |
23
|
|
|
|
|
|
|
|
24
|
85
|
100
|
|
|
|
140
|
if (@$values) { |
25
|
|
|
|
|
|
|
# Negate the default if the arg appears on the command |
26
|
|
|
|
|
|
|
# line |
27
|
11
|
|
|
|
|
34
|
$namespace->set_attr($spec->{dest}, !$default->[0]); |
28
|
|
|
|
|
|
|
} else { |
29
|
74
|
|
|
|
|
183
|
$namespace->set_attr($spec->{dest}, $default->[0]); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# make no_arg available |
33
|
85
|
|
|
|
|
207
|
$namespace->set_attr( 'no_' . $spec->{dest}, !$namespace->get_attr($spec->{dest}) ); |
34
|
|
|
|
|
|
|
|
35
|
85
|
|
|
|
|
180
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Don't set it to undef. We may operate on a namespace with this |
39
|
|
|
|
|
|
|
# attr already set. In that case we don't want to override it. |
40
|
66
|
100
|
|
|
|
130
|
return unless @$values; |
41
|
|
|
|
|
|
|
|
42
|
49
|
|
|
|
|
59
|
my $v = $values->[0]; |
43
|
|
|
|
|
|
|
|
44
|
49
|
|
|
|
|
97
|
$namespace->set_attr($spec->{dest}, $v); |
45
|
|
|
|
|
|
|
|
46
|
49
|
|
|
|
|
77
|
return ''; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 AUTHOR |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Mytram (original author) |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Mytram. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This is free software, licensed under: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |