line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::App::AppOptionCollection; |
2
|
9
|
|
|
9
|
|
501
|
use warnings; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
309
|
|
3
|
9
|
|
|
9
|
|
47
|
use strict; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
337
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
63
|
use base 'Test::Smoke::ObjectBase'; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
5144
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Test::Smoke::App::AppOptionCollection - A collection of AppOption objects. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 Test::Smoke::App::AppOptionCollection->new() |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head3 Arguments |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
An optional list of L objects. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head3 Returns |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
An instatiated object. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head3 Exceptions |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
None. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
27
|
|
|
27
|
1
|
204
|
my $class = shift; |
33
|
|
|
|
|
|
|
|
34
|
27
|
|
|
|
|
229
|
my $struct = { |
35
|
|
|
|
|
|
|
_added_options => [], |
36
|
|
|
|
|
|
|
_options_hash => {}, |
37
|
|
|
|
|
|
|
_options_list => [], |
38
|
|
|
|
|
|
|
_helptext => '', |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
27
|
|
|
|
|
99
|
my $self = bless $struct, $class; |
42
|
27
|
|
|
|
|
141
|
$self->add(@_); |
43
|
|
|
|
|
|
|
|
44
|
27
|
|
|
|
|
214
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 $collection->add(@arguments) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Add the L option and default to the collection. Also add the |
50
|
|
|
|
|
|
|
Lshow_helptext()> to the running helptext variable. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head3 Arguments |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
A list of L objects. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 Returns |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The object. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head3 Exceptions |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
None. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub add { |
67
|
651
|
|
|
651
|
1
|
1048
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
651
|
|
|
|
|
1234
|
for my $tsao (@_) { |
70
|
624
|
|
|
|
|
919
|
push @{$self->added_options}, $tsao; |
|
624
|
|
|
|
|
2156
|
|
71
|
624
|
|
|
|
|
2252
|
$self->options_hash->{$tsao->name} = $tsao->default; |
72
|
567
|
|
|
|
|
2087
|
push @{ $self->options_list }, $tsao->gol_option |
73
|
624
|
100
|
|
|
|
1283
|
if !grep $_ eq $tsao->gol_option, @{$self->options_list}; |
|
624
|
|
|
|
|
2147
|
|
74
|
624
|
100
|
|
|
|
2183
|
$self->add_helptext($tsao->show_helptext) if $tsao->helptext; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
651
|
|
|
|
|
1664
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 $collection->add_helptext($string) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Adds a string to the currently build up helptext variable. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub add_helptext { |
87
|
705
|
|
|
705
|
1
|
1227
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
705
|
|
|
|
|
2375
|
$self->{_helptext} .= shift; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 $collection->options_with_default() |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 Arguments |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
None |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head3 Returns |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
A hasref to a struct with only the defaults set from object construction. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub options_with_default { |
105
|
26
|
|
|
26
|
1
|
71
|
my $self = shift; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my %defaults = map { |
108
|
487
|
|
|
|
|
1590
|
+($_->name => $_->default) |
109
|
|
|
|
|
|
|
} grep |
110
|
|
|
|
|
|
|
$_->had_default |
111
|
26
|
|
|
|
|
65
|
, @{$self->added_options}; |
|
26
|
|
|
|
|
126
|
|
112
|
|
|
|
|
|
|
|
113
|
26
|
|
|
|
|
243
|
return \%defaults; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 $collection->options_for_cli() |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head3 Arguments |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
None |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head3 Returns |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
A hashref with options that have a CODEref as default. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head3 Exceptions |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
None |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub options_for_cli { |
133
|
26
|
|
|
26
|
1
|
103
|
my $self = shift; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my %clis = map { |
136
|
26
|
|
|
|
|
136
|
+($_->name => $_->default) |
137
|
|
|
|
|
|
|
} grep |
138
|
|
|
|
|
|
|
$_->had_default && ref($_->default) eq 'CODE' |
139
|
26
|
|
100
|
|
|
74
|
, @{$self->added_options}; |
|
26
|
|
|
|
|
131
|
|
140
|
26
|
|
|
|
|
185
|
return \%clis; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 $collection->all_options() |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head3 Arguments |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
None. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head3 Returns |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
A hashref with all options and theire coded default. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head3 Exceptions |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
None. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub all_options { |
160
|
26
|
|
|
26
|
1
|
70
|
my $self = shift; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
return { |
163
|
|
|
|
|
|
|
map { |
164
|
622
|
|
|
|
|
1964
|
+($_->name => $_->default) |
165
|
26
|
|
|
|
|
50
|
} @{$self->added_options} |
|
26
|
|
|
|
|
120
|
|
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
(c) 2002-2013, Abe Timmerman All rights reserved. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
With contributions from Jarkko Hietaniemi, Merijn Brand, Campo |
176
|
|
|
|
|
|
|
Weijerman, Alan Burlison, Allen Smith, Alain Barbet, Dominic Dunlop, |
177
|
|
|
|
|
|
|
Rich Rauenzahn, David Cantrell. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
180
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
See: |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=over 4 |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * L |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * L |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=back |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
193
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
194
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |