line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Getopt::ArgParse::ActionStore; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
1114
|
use strict; |
|
20
|
|
|
|
|
21
|
|
|
20
|
|
|
|
|
532
|
|
4
|
20
|
|
|
20
|
|
58
|
use warnings; |
|
20
|
|
|
|
|
21
|
|
|
20
|
|
|
|
|
408
|
|
5
|
20
|
|
|
20
|
|
64
|
use Carp; |
|
20
|
|
|
|
|
25
|
|
|
20
|
|
|
|
|
1029
|
|
6
|
|
|
|
|
|
|
|
7
|
20
|
|
|
20
|
|
76
|
use Getopt::ArgParse::Parser; |
|
20
|
|
|
|
|
17
|
|
|
20
|
|
|
|
|
3015
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub apply { |
10
|
152
|
|
|
152
|
0
|
719
|
my $self = shift; |
11
|
|
|
|
|
|
|
|
12
|
152
|
|
|
|
|
151
|
my ($spec, $namespace, $values) = @_; |
13
|
152
|
|
50
|
|
|
225
|
$values ||= []; |
14
|
|
|
|
|
|
|
|
15
|
152
|
100
|
|
|
|
221
|
return sprintf( |
16
|
|
|
|
|
|
|
'%s can only have one value', |
17
|
|
|
|
|
|
|
$spec->{dest}, |
18
|
|
|
|
|
|
|
) if @$values > 1; |
19
|
|
|
|
|
|
|
|
20
|
151
|
100
|
|
|
|
224
|
if ($spec->{type} == Getopt::ArgParse::Parser::TYPE_BOOL) { |
21
|
|
|
|
|
|
|
# If there is default true or false |
22
|
85
|
|
100
|
|
|
294
|
my $default = $spec->{default} || [ 0 ]; |
23
|
|
|
|
|
|
|
|
24
|
85
|
100
|
|
|
|
131
|
if (@$values) { |
25
|
|
|
|
|
|
|
# Negate the default if the arg appears on the command |
26
|
|
|
|
|
|
|
# line |
27
|
11
|
|
|
|
|
25
|
$namespace->set_attr($spec->{dest}, !$default->[0]); |
28
|
|
|
|
|
|
|
} else { |
29
|
74
|
|
|
|
|
180
|
$namespace->set_attr($spec->{dest}, $default->[0]); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# make no_arg available |
33
|
85
|
|
|
|
|
199
|
$namespace->set_attr( 'no_' . $spec->{dest}, !$namespace->get_attr($spec->{dest}) ); |
34
|
|
|
|
|
|
|
|
35
|
85
|
|
|
|
|
154
|
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
|
|
|
|
109
|
return unless @$values; |
41
|
|
|
|
|
|
|
|
42
|
49
|
|
|
|
|
56
|
my $v = $values->[0]; |
43
|
|
|
|
|
|
|
|
44
|
49
|
|
|
|
|
81
|
$namespace->set_attr($spec->{dest}, $v); |
45
|
|
|
|
|
|
|
|
46
|
49
|
|
|
|
|
71
|
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 |