line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Getopt::Kingpin::Flag; |
2
|
31
|
|
|
31
|
|
537
|
use 5.008001; |
|
31
|
|
|
|
|
102
|
|
3
|
31
|
|
|
31
|
|
165
|
use strict; |
|
31
|
|
|
|
|
70
|
|
|
31
|
|
|
|
|
798
|
|
4
|
31
|
|
|
31
|
|
155
|
use warnings; |
|
31
|
|
|
|
|
64
|
|
|
31
|
|
|
|
|
1077
|
|
5
|
31
|
|
|
31
|
|
13407
|
use Getopt::Kingpin::Base -base; |
|
31
|
|
|
|
|
101
|
|
|
31
|
|
|
|
|
287
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.11"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has _placeholder => undef; |
10
|
|
|
|
|
|
|
has _hidden => 0; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub placeholder { |
13
|
7
|
|
|
7
|
1
|
29
|
my $self = shift; |
14
|
7
|
|
|
|
|
14
|
my $placeholder = shift; |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
|
|
120
|
$self->_placeholder($placeholder); |
17
|
|
|
|
|
|
|
|
18
|
7
|
|
|
|
|
86
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub hidden { |
22
|
8
|
|
|
8
|
1
|
17
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
8
|
|
|
|
|
141
|
$self->_hidden(1); |
25
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
100
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub help_str { |
30
|
268
|
|
|
268
|
1
|
414
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
268
|
|
|
|
|
578
|
my $ret = ["", "", ""]; |
33
|
|
|
|
|
|
|
|
34
|
268
|
100
|
|
|
|
4512
|
if (defined $self->short_name) { |
35
|
30
|
|
|
|
|
601
|
$ret->[0] = sprintf "-%s", $self->short_name; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
268
|
|
|
|
|
5440
|
my $default = $self->_default; |
39
|
268
|
|
|
|
|
1494
|
my $printable_default = defined $default; |
40
|
268
|
100
|
|
|
|
567
|
if (ref $default) { |
41
|
6
|
|
100
|
|
|
34
|
$printable_default = Scalar::Util::blessed($default) && overload::Method($default, q[""]); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
268
|
100
|
|
|
|
4468
|
if ($self->type eq "Bool") { |
|
|
100
|
|
|
|
|
|
45
|
194
|
|
|
|
|
4119
|
$ret->[1] = sprintf "--%s", $self->name; |
46
|
|
|
|
|
|
|
} elsif ($self->is_hash) { |
47
|
6
|
100
|
100
|
|
|
245
|
if (defined $self->_placeholder and $self->_placeholder =~ /=/) { |
|
|
100
|
|
|
|
|
|
48
|
2
|
|
|
|
|
78
|
$ret->[1] = sprintf '--%s %s', $self->name, $self->_placeholder; |
49
|
|
|
|
|
|
|
} elsif (defined $self->_placeholder) { |
50
|
2
|
|
|
|
|
121
|
$ret->[1] = sprintf '--%s KEY=%s', $self->name, $self->_placeholder; |
51
|
|
|
|
|
|
|
} else { |
52
|
2
|
|
|
|
|
81
|
$ret->[1] = sprintf "--%s KEY=VALUE", $self->name; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} else { |
55
|
68
|
100
|
|
|
|
2836
|
if (defined $self->_placeholder) { |
|
|
100
|
|
|
|
|
|
56
|
10
|
|
|
|
|
196
|
$ret->[1] = sprintf '--%s=%s', $self->name, $self->_placeholder; |
57
|
|
|
|
|
|
|
} elsif ($printable_default) { |
58
|
10
|
|
|
|
|
204
|
$ret->[1] = sprintf '--%s="%s"', $self->name, $default; |
59
|
|
|
|
|
|
|
} else { |
60
|
48
|
|
|
|
|
997
|
$ret->[1] = sprintf "--%s=%s", $self->name, uc $self->name; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
268
|
100
|
|
|
|
6366
|
$ret->[2] = defined $self->description ? $self->description : ""; |
65
|
|
|
|
|
|
|
|
66
|
268
|
|
|
|
|
6082
|
return $ret; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
__END__ |