line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Getopt::ArgParse::ActionStore; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
1150
|
use strict; |
|
20
|
|
|
|
|
27
|
|
|
20
|
|
|
|
|
637
|
|
4
|
20
|
|
|
20
|
|
95
|
use warnings; |
|
20
|
|
|
|
|
23
|
|
|
20
|
|
|
|
|
427
|
|
5
|
20
|
|
|
20
|
|
76
|
use Carp; |
|
20
|
|
|
|
|
21
|
|
|
20
|
|
|
|
|
1261
|
|
6
|
|
|
|
|
|
|
|
7
|
20
|
|
|
20
|
|
137
|
use Getopt::ArgParse::Parser; |
|
20
|
|
|
|
|
25
|
|
|
20
|
|
|
|
|
3465
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub apply { |
10
|
152
|
|
|
152
|
0
|
1006
|
my $self = shift; |
11
|
|
|
|
|
|
|
|
12
|
152
|
|
|
|
|
182
|
my ($spec, $namespace, $values) = @_; |
13
|
152
|
|
50
|
|
|
301
|
$values ||= []; |
14
|
|
|
|
|
|
|
|
15
|
152
|
100
|
|
|
|
268
|
return sprintf( |
16
|
|
|
|
|
|
|
'%s can only have one value', |
17
|
|
|
|
|
|
|
$spec->{dest}, |
18
|
|
|
|
|
|
|
) if @$values > 1; |
19
|
|
|
|
|
|
|
|
20
|
151
|
100
|
|
|
|
276
|
if ($spec->{type} == Getopt::ArgParse::Parser::TYPE_BOOL) { |
21
|
|
|
|
|
|
|
# If there is default true or false |
22
|
85
|
|
100
|
|
|
366
|
my $default = $spec->{default} || [ 0 ]; |
23
|
|
|
|
|
|
|
|
24
|
85
|
100
|
|
|
|
156
|
if (@$values) { |
25
|
|
|
|
|
|
|
# Negate the default if the arg appears on the command |
26
|
|
|
|
|
|
|
# line |
27
|
11
|
|
|
|
|
36
|
$namespace->set_attr($spec->{dest}, !$default->[0]); |
28
|
|
|
|
|
|
|
} else { |
29
|
74
|
|
|
|
|
208
|
$namespace->set_attr($spec->{dest}, $default->[0]); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# make no_arg available |
33
|
85
|
|
|
|
|
241
|
$namespace->set_attr( 'no_' . $spec->{dest}, !$namespace->get_attr($spec->{dest}) ); |
34
|
|
|
|
|
|
|
|
35
|
85
|
|
|
|
|
201
|
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
|
|
|
|
137
|
return unless @$values; |
41
|
|
|
|
|
|
|
|
42
|
49
|
|
|
|
|
87
|
my $v = $values->[0]; |
43
|
|
|
|
|
|
|
|
44
|
49
|
|
|
|
|
111
|
$namespace->set_attr($spec->{dest}, $v); |
45
|
|
|
|
|
|
|
|
46
|
49
|
|
|
|
|
90
|
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 |