line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::App::AppOptionCollection; |
2
|
9
|
|
|
9
|
|
536
|
use warnings; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
311
|
|
3
|
9
|
|
|
9
|
|
57
|
use strict; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
346
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
62
|
use base 'Test::Smoke::ObjectBase'; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
5005
|
|
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
|
225
|
my $class = shift; |
33
|
|
|
|
|
|
|
|
34
|
27
|
|
|
|
|
256
|
my $struct = { |
35
|
|
|
|
|
|
|
_added_options => [], |
36
|
|
|
|
|
|
|
_options_hash => {}, |
37
|
|
|
|
|
|
|
_options_list => [], |
38
|
|
|
|
|
|
|
_helptext => '', |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
27
|
|
|
|
|
94
|
my $self = bless $struct, $class; |
42
|
27
|
|
|
|
|
205
|
$self->add(@_); |
43
|
|
|
|
|
|
|
|
44
|
27
|
|
|
|
|
247
|
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
|
662
|
|
|
662
|
1
|
1136
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
662
|
|
|
|
|
1315
|
for my $tsao (@_) { |
70
|
635
|
|
|
|
|
946
|
push @{$self->added_options}, $tsao; |
|
635
|
|
|
|
|
2318
|
|
71
|
635
|
|
|
|
|
2344
|
$self->options_hash->{$tsao->name} = $tsao->default; |
72
|
578
|
|
|
|
|
2213
|
push @{ $self->options_list }, $tsao->gol_option |
73
|
635
|
100
|
|
|
|
1343
|
if !grep $_ eq $tsao->gol_option, @{$self->options_list}; |
|
635
|
|
|
|
|
2307
|
|
74
|
635
|
100
|
|
|
|
2279
|
$self->add_helptext($tsao->show_helptext) if $tsao->helptext; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
662
|
|
|
|
|
1729
|
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
|
716
|
|
|
716
|
1
|
1299
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
716
|
|
|
|
|
2493
|
$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
|
75
|
my $self = shift; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my %defaults = map { |
108
|
498
|
|
|
|
|
1614
|
+($_->name => $_->default) |
109
|
|
|
|
|
|
|
} grep |
110
|
|
|
|
|
|
|
$_->had_default |
111
|
26
|
|
|
|
|
64
|
, @{$self->added_options}; |
|
26
|
|
|
|
|
126
|
|
112
|
|
|
|
|
|
|
|
113
|
26
|
|
|
|
|
251
|
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
|
86
|
my $self = shift; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my %clis = map { |
136
|
26
|
|
|
|
|
140
|
+($_->name => $_->default) |
137
|
|
|
|
|
|
|
} grep |
138
|
|
|
|
|
|
|
$_->had_default && ref($_->default) eq 'CODE' |
139
|
26
|
|
100
|
|
|
59
|
, @{$self->added_options}; |
|
26
|
|
|
|
|
124
|
|
140
|
26
|
|
|
|
|
169
|
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
|
73
|
my $self = shift; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
return { |
163
|
|
|
|
|
|
|
map { |
164
|
633
|
|
|
|
|
2302
|
+($_->name => $_->default) |
165
|
26
|
|
|
|
|
56
|
} @{$self->added_options} |
|
26
|
|
|
|
|
130
|
|
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 |