line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Getopt::Kingpin::Flag; |
2
|
31
|
|
|
31
|
|
511
|
use 5.008001; |
|
31
|
|
|
|
|
110
|
|
3
|
31
|
|
|
31
|
|
157
|
use strict; |
|
31
|
|
|
|
|
52
|
|
|
31
|
|
|
|
|
677
|
|
4
|
31
|
|
|
31
|
|
172
|
use warnings; |
|
31
|
|
|
|
|
55
|
|
|
31
|
|
|
|
|
1128
|
|
5
|
31
|
|
|
31
|
|
12656
|
use Getopt::Kingpin::Base -base; |
|
31
|
|
|
|
|
81
|
|
|
31
|
|
|
|
|
306
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.10"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has _placeholder => undef; |
10
|
|
|
|
|
|
|
has _hidden => 0; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub placeholder { |
13
|
7
|
|
|
7
|
1
|
12
|
my $self = shift; |
14
|
7
|
|
|
|
|
14
|
my $placeholder = shift; |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
|
|
108
|
$self->_placeholder($placeholder); |
17
|
|
|
|
|
|
|
|
18
|
7
|
|
|
|
|
82
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub hidden { |
22
|
8
|
|
|
8
|
1
|
14
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
8
|
|
|
|
|
134
|
$self->_hidden(1); |
25
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
107
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub help_str { |
30
|
268
|
|
|
268
|
1
|
402
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
268
|
|
|
|
|
538
|
my $ret = ["", "", ""]; |
33
|
|
|
|
|
|
|
|
34
|
268
|
100
|
|
|
|
4185
|
if (defined $self->short_name) { |
35
|
30
|
|
|
|
|
628
|
$ret->[0] = sprintf "-%s", $self->short_name; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
268
|
|
|
|
|
5086
|
my $default = $self->_default; |
39
|
268
|
|
|
|
|
1319
|
my $printable_default = defined $default; |
40
|
268
|
100
|
|
|
|
527
|
if (ref $default) { |
41
|
6
|
|
100
|
|
|
32
|
$printable_default = Scalar::Util::blessed($default) && overload::Method($default, q[""]); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
268
|
100
|
|
|
|
4091
|
if ($self->type eq "Bool") { |
|
|
100
|
|
|
|
|
|
45
|
194
|
|
|
|
|
4093
|
$ret->[1] = sprintf "--%s", $self->name; |
46
|
|
|
|
|
|
|
} elsif ($self->is_hash) { |
47
|
6
|
100
|
100
|
|
|
215
|
if (defined $self->_placeholder and $self->_placeholder =~ /=/) { |
|
|
100
|
|
|
|
|
|
48
|
2
|
|
|
|
|
72
|
$ret->[1] = sprintf '--%s %s', $self->name, $self->_placeholder; |
49
|
|
|
|
|
|
|
} elsif (defined $self->_placeholder) { |
50
|
2
|
|
|
|
|
94
|
$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
|
|
|
|
2650
|
if (defined $self->_placeholder) { |
|
|
100
|
|
|
|
|
|
56
|
10
|
|
|
|
|
199
|
$ret->[1] = sprintf '--%s=%s', $self->name, $self->_placeholder; |
57
|
|
|
|
|
|
|
} elsif ($printable_default) { |
58
|
10
|
|
|
|
|
198
|
$ret->[1] = sprintf '--%s="%s"', $self->name, $default; |
59
|
|
|
|
|
|
|
} else { |
60
|
48
|
|
|
|
|
914
|
$ret->[1] = sprintf "--%s=%s", $self->name, uc $self->name; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
268
|
100
|
|
|
|
6036
|
$ret->[2] = defined $self->description ? $self->description : ""; |
65
|
|
|
|
|
|
|
|
66
|
268
|
|
|
|
|
5499
|
return $ret; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
__END__ |