line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Task; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
454
|
use 5.018; |
|
1
|
|
|
|
|
3
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
19
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Venus::Class 'attr', 'base', 'with'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
base 'Venus::Kind::Utility'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Venus::Role::Buildable'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require POSIX; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# ATTRIBUTES |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
attr 'data'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# BUILDERS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub build_arg { |
23
|
44
|
|
|
44
|
0
|
86
|
my ($self, $data) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return { |
26
|
44
|
|
|
|
|
158
|
data => $data, |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub build_args { |
31
|
57
|
|
|
57
|
0
|
108
|
my ($self, $args) = @_; |
32
|
|
|
|
|
|
|
|
33
|
57
|
|
|
|
|
94
|
my $data = $args->{data}; |
34
|
|
|
|
|
|
|
|
35
|
57
|
50
|
|
|
|
176
|
$data = defined $data ? (ref $data eq 'ARRAY' ? $data : [$data]) : [@ARGV]; |
|
|
100
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
57
|
|
|
|
|
95
|
$args->{data} = $data; |
38
|
|
|
|
|
|
|
|
39
|
57
|
|
|
|
|
147
|
return $args; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# HOOKS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _exit { |
45
|
0
|
|
|
0
|
|
0
|
POSIX::_exit(shift); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _system { |
49
|
0
|
|
|
0
|
|
0
|
local $SIG{__WARN__} = sub {}; |
|
|
|
|
0
|
|
|
|
50
|
0
|
0
|
|
|
|
0
|
CORE::system(@_) or return 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _print { |
54
|
0
|
|
|
0
|
|
0
|
CORE::print(@_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub args { |
60
|
10
|
|
|
10
|
1
|
40
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
10
|
|
|
|
|
38
|
return {}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub cli { |
66
|
38
|
|
|
38
|
0
|
3455
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
38
|
|
|
|
|
1124
|
require Venus::Cli; |
69
|
|
|
|
|
|
|
|
70
|
38
|
|
66
|
|
|
381
|
return $self->{'$cli'} ||= Venus::Cli->new(data => $self->data); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub cmds { |
74
|
13
|
|
|
13
|
1
|
25
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
|
76
|
13
|
|
|
|
|
32
|
return {}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub execute { |
80
|
3
|
|
|
3
|
1
|
8
|
my ($self) = @_; |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
|
|
12
|
$self->prepare; |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
9
|
my $parsed = $self->cli->parsed; |
85
|
|
|
|
|
|
|
|
86
|
3
|
|
|
|
|
40
|
$self->startup($parsed); |
87
|
3
|
|
|
|
|
62
|
$self->handler($parsed); |
88
|
3
|
|
|
|
|
28
|
$self->shutdown($parsed); |
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
33
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub exit { |
94
|
12
|
|
|
12
|
1
|
39
|
my ($self, $code, $method, @args) = @_; |
95
|
|
|
|
|
|
|
|
96
|
12
|
50
|
|
|
|
53
|
my $result = $self->$method(@args) ? 0 : 1 if $method; |
|
|
100
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
12
|
|
50
|
|
|
48
|
$code //= $result // 0; |
|
|
|
66
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
12
|
|
|
|
|
43
|
_exit($code); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub fail { |
104
|
4
|
|
|
4
|
1
|
14
|
my ($self, $method, @args) = @_; |
105
|
|
|
|
|
|
|
|
106
|
4
|
|
|
|
|
17
|
return $self->exit(1, $method, @args); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub handler { |
110
|
3
|
|
|
3
|
1
|
10
|
my ($self, $data) = @_; |
111
|
|
|
|
|
|
|
|
112
|
3
|
100
|
|
|
|
20
|
$self->usage if $data->{help}; |
113
|
|
|
|
|
|
|
|
114
|
3
|
|
|
|
|
23
|
return $self; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub help { |
118
|
4
|
|
|
4
|
1
|
13
|
my ($self) = @_; |
119
|
|
|
|
|
|
|
|
120
|
4
|
|
|
|
|
19
|
return $self->cli->help; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub log { |
124
|
26
|
|
|
26
|
0
|
51
|
my ($self) = @_; |
125
|
|
|
|
|
|
|
|
126
|
26
|
|
|
|
|
117
|
require Venus::Log; |
127
|
|
|
|
|
|
|
|
128
|
26
|
|
33
|
|
|
240
|
return $self->{'$log'} ||= Venus::Log->new( |
129
|
|
|
|
|
|
|
level => $self->log_level, |
130
|
|
|
|
|
|
|
handler => $self->defer('output') |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub log_debug { |
135
|
1
|
|
|
1
|
1
|
4
|
my ($self, @args) = @_; |
136
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
5
|
return $self->log->debug(@args); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub log_error { |
141
|
3
|
|
|
3
|
1
|
13
|
my ($self, @args) = @_; |
142
|
|
|
|
|
|
|
|
143
|
3
|
|
|
|
|
12
|
return $self->log->error(@args); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub log_fatal { |
147
|
1
|
|
|
1
|
1
|
5
|
my ($self, @args) = @_; |
148
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
4
|
return $self->log->fatal(@args); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub log_info { |
153
|
5
|
|
|
5
|
1
|
23
|
my ($self, @args) = @_; |
154
|
|
|
|
|
|
|
|
155
|
5
|
|
|
|
|
17
|
return $self->log->info(@args); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub log_level { |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
0
|
|
0
|
return 'info'; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub log_trace { |
164
|
1
|
|
|
1
|
1
|
5
|
my ($self, @args) = @_; |
165
|
|
|
|
|
|
|
|
166
|
1
|
|
|
|
|
4
|
return $self->log->trace(@args); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub log_warn { |
170
|
1
|
|
|
1
|
1
|
7
|
my ($self, @args) = @_; |
171
|
|
|
|
|
|
|
|
172
|
1
|
|
|
|
|
3
|
return $self->log->warn(@args); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub name { |
176
|
13
|
|
|
13
|
1
|
29
|
my ($self) = @_; |
177
|
|
|
|
|
|
|
|
178
|
13
|
|
|
|
|
49
|
return $0; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub okay { |
182
|
2
|
|
|
2
|
1
|
7
|
my ($self, $method, @args) = @_; |
183
|
|
|
|
|
|
|
|
184
|
2
|
|
|
|
|
7
|
return $self->exit(0, $method, @args); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub opts { |
188
|
8
|
|
|
8
|
1
|
53
|
my ($self) = @_; |
189
|
|
|
|
|
|
|
|
190
|
8
|
|
|
|
|
30
|
return {}; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub output { |
194
|
13
|
|
|
13
|
1
|
55
|
my ($self, $level, @data) = @_; |
195
|
|
|
|
|
|
|
|
196
|
13
|
|
|
|
|
82
|
local $|=1; |
197
|
|
|
|
|
|
|
|
198
|
13
|
50
|
|
|
|
82
|
_print(@data, "\n") if @data; |
199
|
|
|
|
|
|
|
|
200
|
13
|
|
|
|
|
110
|
return $self; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub prepare { |
204
|
13
|
|
|
13
|
1
|
50
|
my ($self) = @_; |
205
|
|
|
|
|
|
|
|
206
|
13
|
|
|
|
|
67
|
my $cli = $self->cli; |
207
|
|
|
|
|
|
|
|
208
|
13
|
|
|
|
|
59
|
$cli->data($self->data); |
209
|
|
|
|
|
|
|
|
210
|
13
|
|
|
|
|
146
|
my $args = $self->args; |
211
|
13
|
|
|
|
|
62
|
my $cmds = $self->cmds; |
212
|
13
|
|
|
|
|
64
|
my $name = $self->name; |
213
|
13
|
|
|
|
|
150
|
my $opts = $self->opts; |
214
|
|
|
|
|
|
|
|
215
|
13
|
|
|
|
|
29
|
$cli->set('arg', $_, $args->{$_}) for sort keys %{$args}; |
|
13
|
|
|
|
|
82
|
|
216
|
13
|
|
|
|
|
27
|
$cli->set('cmd', $_, $cmds->{$_}) for sort keys %{$cmds}; |
|
13
|
|
|
|
|
46
|
|
217
|
13
|
|
|
|
|
29
|
$cli->set('opt', $_, $opts->{$_}) for sort keys %{$opts}; |
|
13
|
|
|
|
|
55
|
|
218
|
|
|
|
|
|
|
|
219
|
13
|
50
|
33
|
|
|
50
|
$cli->set('str', 'name', $name) if !$cli->str('name') && $name; |
220
|
|
|
|
|
|
|
|
221
|
13
|
100
|
66
|
|
|
136
|
if ($self->can('description') && (my $description = $self->description)) { |
222
|
1
|
50
|
|
|
|
5
|
$cli->set('str', 'description', $description) if !$cli->str('description'); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
13
|
100
|
66
|
|
|
109
|
if ($self->can('header') && (my $header = $self->header)) { |
226
|
1
|
50
|
|
|
|
15
|
$cli->set('str', 'header', $header) if !$cli->str('header'); |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
13
|
100
|
66
|
|
|
100
|
if ($self->can('footer') && (my $footer = $self->footer)) { |
230
|
1
|
50
|
|
|
|
10
|
$cli->set('str', 'footer', $footer) if !$cli->str('footer'); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
13
|
|
|
|
|
55
|
$self->log->do('level' => $self->log_level)->handler($self->defer('output')); |
234
|
|
|
|
|
|
|
|
235
|
13
|
|
|
|
|
169
|
return $self; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
sub pass { |
239
|
2
|
|
|
2
|
1
|
6
|
my ($self, $method, @args) = @_; |
240
|
|
|
|
|
|
|
|
241
|
2
|
|
|
|
|
9
|
return $self->exit(0, $method, @args); |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub run { |
245
|
2
|
|
|
2
|
1
|
11
|
my ($self, @args) = @_; |
246
|
|
|
|
|
|
|
|
247
|
2
|
|
33
|
|
|
14
|
my $CAN_RUN = not(caller(1)) || scalar(caller(1)) eq 'main'; |
248
|
|
|
|
|
|
|
|
249
|
2
|
50
|
33
|
|
|
12
|
$self->class->new(@args)->maybe('execute') if $ENV{VENUS_TASK_RUN} && $CAN_RUN; |
250
|
|
|
|
|
|
|
|
251
|
2
|
|
|
|
|
17
|
return $self; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub startup { |
255
|
3
|
|
|
3
|
1
|
10
|
my ($self, $data) = @_; |
256
|
|
|
|
|
|
|
|
257
|
3
|
|
|
|
|
14
|
return $self; |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
sub shutdown { |
261
|
3
|
|
|
3
|
1
|
8
|
my ($self, $data) = @_; |
262
|
|
|
|
|
|
|
|
263
|
3
|
|
|
|
|
13
|
return $self; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub system { |
267
|
2
|
|
|
2
|
1
|
9
|
my ($self, @args) = @_; |
268
|
|
|
|
|
|
|
|
269
|
2
|
100
|
|
|
|
9
|
(_system(@args) == 0) or $self->throw('error_on_system_call', \@args, $?)->error; |
270
|
|
|
|
|
|
|
|
271
|
1
|
|
|
|
|
16
|
return $self; |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub test { |
275
|
2
|
|
|
2
|
1
|
6
|
my ($self, @args) = @_; |
276
|
|
|
|
|
|
|
|
277
|
2
|
|
|
|
|
5
|
return $self->cli->test(@args); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub usage { |
281
|
2
|
|
|
2
|
1
|
6
|
my ($self) = @_; |
282
|
|
|
|
|
|
|
|
283
|
2
|
|
|
2
|
|
17
|
$self->fail(sub{$self->log_info($self->help)}); |
|
2
|
|
|
|
|
10
|
|
284
|
|
|
|
|
|
|
|
285
|
2
|
|
|
|
|
22
|
return $self; |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
# ERRORS |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub error_on_system_call { |
291
|
2
|
|
|
2
|
1
|
7
|
my ($self, $args, $err) = @_; |
292
|
|
|
|
|
|
|
|
293
|
2
|
50
|
|
|
|
6
|
$err = "" if !defined $err; |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
return { |
296
|
2
|
|
|
|
|
22
|
name => 'on.system.call', |
297
|
|
|
|
|
|
|
message => "Can't make system call \"@$args\": $err", |
298
|
|
|
|
|
|
|
stash => { |
299
|
|
|
|
|
|
|
args => $args, |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
}; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
1; |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=head1 NAME |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Venus::Task - Task Class |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=cut |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head1 ABSTRACT |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Task Class for Perl 5 |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=cut |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=head1 SYNOPSIS |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
package Example; |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
use base 'Venus::Task'; |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
package main; |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
my $task = Example->new(['--help']); |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# bless({...}, 'Example') |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=cut |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
=head1 DESCRIPTION |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
This package provides a superclass, methods, and a simple framework for |
337
|
|
|
|
|
|
|
creating CLIs (command-line interfaces). |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=cut |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
This package has the following attributes: |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=cut |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=head2 data |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
data(ArrayRef $data) (ArrayRef) |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
The data attribute is read-write, accepts C<(ArrayRef)> values, and is |
352
|
|
|
|
|
|
|
optional. |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
I> |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=over 4 |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=item data example 1 |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# given: synopsis |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
package main; |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
my $set_data = $task->data([1..4]); |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
# [1..4] |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=back |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
=over 4 |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
=item data example 2 |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
# given: synopsis |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
# given: example-1 data |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
package main; |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
my $get_data = $task->data; |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
# [1..4] |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=back |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=cut |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=head1 INHERITS |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
This package inherits behaviors from: |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
L |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=cut |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=head1 INTEGRATES |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
This package integrates behaviors from: |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
L |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=cut |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=head1 METHODS |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
This package provides the following methods: |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=cut |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
=head2 args |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
args() (HashRef) |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
The args method can be overridden and returns a hashref suitable to be passed |
415
|
|
|
|
|
|
|
to the L method as type C<"arg">. An C<"arg"> is a CLI |
416
|
|
|
|
|
|
|
positional argument. |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
I> |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=over 4 |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=item args example 1 |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
# given: synopsis |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
package main; |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
my $args = $task->args; |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
# {} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=back |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
=over 4 |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
=item args example 2 |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
package Example; |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
use base 'Venus::Task'; |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
sub args { |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
return { |
445
|
|
|
|
|
|
|
name => { |
446
|
|
|
|
|
|
|
help => 'Name of user', |
447
|
|
|
|
|
|
|
}, |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
package main; |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
my $task = Example->new; |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
my $args = $task->args; |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
# { |
458
|
|
|
|
|
|
|
# name => { |
459
|
|
|
|
|
|
|
# help => 'Name of user', |
460
|
|
|
|
|
|
|
# }, |
461
|
|
|
|
|
|
|
# } |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=back |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=cut |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=head2 cmds |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
cmds() (HashRef) |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
The cmds method can be overridden and returns a hashref suitable to be passed |
472
|
|
|
|
|
|
|
to the L method as type C<"cmd">. A C<"cmd"> is a CLI command |
473
|
|
|
|
|
|
|
which maps to an positional argument declare by L. |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
I> |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=over 4 |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=item cmds example 1 |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
# given: synopsis |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
package main; |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
my $cmds = $task->cmds; |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
# {} |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=back |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=over 4 |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=item cmds example 2 |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
package Example; |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
use base 'Venus::Task'; |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
sub args { |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
return { |
502
|
|
|
|
|
|
|
op => { |
503
|
|
|
|
|
|
|
help => 'Name of operation', |
504
|
|
|
|
|
|
|
}, |
505
|
|
|
|
|
|
|
} |
506
|
|
|
|
|
|
|
} |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
sub cmds { |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
return { |
511
|
|
|
|
|
|
|
init => { |
512
|
|
|
|
|
|
|
help => 'Initialize the system', |
513
|
|
|
|
|
|
|
arg => 'op', |
514
|
|
|
|
|
|
|
}, |
515
|
|
|
|
|
|
|
} |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
package main; |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
my $task = Example->new; |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
my $cmds = $task->cmds; |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
# { |
525
|
|
|
|
|
|
|
# init => { |
526
|
|
|
|
|
|
|
# help => 'Initialize the system', |
527
|
|
|
|
|
|
|
# arg => 'op', |
528
|
|
|
|
|
|
|
# }, |
529
|
|
|
|
|
|
|
# } |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=back |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=cut |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=head2 description |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
description() (Task) |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
The description method doesn't exist on the L superclass but if |
540
|
|
|
|
|
|
|
defined returns a string that will be used as the CLI "description" (before the |
541
|
|
|
|
|
|
|
arguments, options, and commands text). |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
I> |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
=over 4 |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=item description example 1 |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
package Example; |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
use base 'Venus::Task'; |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
sub description { |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
"This text used in the description area of the usage text" |
556
|
|
|
|
|
|
|
} |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
package main; |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
my $task = Example->new; |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
my $description = $task->description; |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
# "..." |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=back |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
=cut |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
=head2 execute |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
execute() (Task) |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
The execute method can be overridden and returns the invocant. This method |
575
|
|
|
|
|
|
|
prepares the L via L, and runs the L, |
576
|
|
|
|
|
|
|
L, and L sequences, passing L to each |
577
|
|
|
|
|
|
|
method. |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
I> |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=over 4 |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=item execute example 1 |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
# given: synopsis |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
package main; |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
my $execute = $task->execute; |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
=back |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=over 4 |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=item execute example 2 |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
package Example; |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
use base 'Venus::Task'; |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
sub args { |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
return { |
606
|
|
|
|
|
|
|
name => { |
607
|
|
|
|
|
|
|
help => 'Name of user', |
608
|
|
|
|
|
|
|
}, |
609
|
|
|
|
|
|
|
} |
610
|
|
|
|
|
|
|
} |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
sub opts { |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
return { |
615
|
|
|
|
|
|
|
sudo => { |
616
|
|
|
|
|
|
|
help => 'Elevate user privileges', |
617
|
|
|
|
|
|
|
alias => ['s'], |
618
|
|
|
|
|
|
|
}, |
619
|
|
|
|
|
|
|
help => { |
620
|
|
|
|
|
|
|
help => 'Display help', |
621
|
|
|
|
|
|
|
alias => ['h'], |
622
|
|
|
|
|
|
|
}, |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
sub startup { |
627
|
|
|
|
|
|
|
my ($self) = @_; |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
$self->{startup} = time; |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
return $self; |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
sub handler { |
635
|
|
|
|
|
|
|
my ($self, $data) = @_; |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
$self->{handler} = time; |
638
|
|
|
|
|
|
|
$self->{parsed} = $data; |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
return $self; |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
sub shutdown { |
644
|
|
|
|
|
|
|
my ($self) = @_; |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
$self->{shutdown} = time; |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
return $self; |
649
|
|
|
|
|
|
|
} |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
package main; |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
my $task = Example->new(['admin', '-s']); |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
my $execute = $task->execute; |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
=back |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
=over 4 |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
=item execute example 3 |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
package Example; |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
use base 'Venus::Task'; |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
sub args { |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
return { |
672
|
|
|
|
|
|
|
name => { |
673
|
|
|
|
|
|
|
help => 'Name of user', |
674
|
|
|
|
|
|
|
}, |
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
sub opts { |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
return { |
681
|
|
|
|
|
|
|
sudo => { |
682
|
|
|
|
|
|
|
help => 'Elevate user privileges', |
683
|
|
|
|
|
|
|
alias => ['s'], |
684
|
|
|
|
|
|
|
}, |
685
|
|
|
|
|
|
|
help => { |
686
|
|
|
|
|
|
|
help => 'Display help', |
687
|
|
|
|
|
|
|
alias => ['h'], |
688
|
|
|
|
|
|
|
}, |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
sub handler { |
693
|
|
|
|
|
|
|
my ($self, $data) = @_; |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
$self->{handler} = time; |
696
|
|
|
|
|
|
|
$self->{parsed} = $data; |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
return $self; |
699
|
|
|
|
|
|
|
} |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
package main; |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
my $task = Example->new(['-s']); |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
my $execute = $task->execute; |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=back |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
=cut |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
=head2 exit |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
exit(Int $code, Str|CodeRef $code, Any @args) (Any) |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
The exit method exits the program using the exit code provided. The exit code |
718
|
|
|
|
|
|
|
defaults to C<0>. Optionally, you can dispatch before exiting by providing a |
719
|
|
|
|
|
|
|
method name or coderef, and arguments. If an exit code of C is provided, |
720
|
|
|
|
|
|
|
the exit code will be determined by the result of the dispatching. |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
I> |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=over 4 |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
=item exit example 1 |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
# given: synopsis |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
package main; |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
my $exit = $task->exit; |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
# () |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=back |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
=over 4 |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
=item exit example 2 |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
# given: synopsis |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
package main; |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
my $exit = $task->exit(0); |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
# () |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=back |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
=over 4 |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=item exit example 3 |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
# given: synopsis |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
package main; |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
my $exit = $task->exit(1); |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
# () |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=back |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
=over 4 |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
=item exit example 4 |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
# given: synopsis |
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
package main; |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
my $exit = $task->exit(1, 'log_error', 'oh no'); |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
# () |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
=back |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=cut |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
=head2 fail |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
fail(Str|CodeRef $code, Any @args) (Any) |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
The fail method exits the program with the exit code C<1>. Optionally, you can |
787
|
|
|
|
|
|
|
dispatch before exiting by providing a method name or coderef, and arguments. |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
I> |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
=over 4 |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
=item fail example 1 |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
# given: synopsis |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
package main; |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
my $fail = $task->fail; |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
# () |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
=back |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
=over 4 |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
=item fail example 2 |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
# given: synopsis |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
package main; |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
my $fail = $task->fail('log_error', 'oh no'); |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
# () |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
=back |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=cut |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
=head2 footer |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
footer() (Task) |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
The footer method doesn't exist on the L superclass but if defined |
826
|
|
|
|
|
|
|
returns a string that will be used as the CLI "footer" (after the arguments, |
827
|
|
|
|
|
|
|
options, and commands text). |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
I> |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
=over 4 |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=item footer example 1 |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
package Example; |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
use base 'Venus::Task'; |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
sub footer { |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
"This text used in the footer area of the usage text" |
842
|
|
|
|
|
|
|
} |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
package main; |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
my $task = Example->new; |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
my $footer = $task->footer; |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
# "..." |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
=back |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
=cut |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
=head2 handler |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
handler(HashRef $data) (Task) |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
The handler method can and should be overridden and returns the invocant. This |
861
|
|
|
|
|
|
|
method is where the central task operations are meant to happen. By default, if |
862
|
|
|
|
|
|
|
not overriden this method calls L if a "help" flag is detected. |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
I> |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
=over 4 |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
=item handler example 1 |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
# given: synopsis |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
package main; |
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
my $handler = $task->handler({}); |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
=back |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
=over 4 |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
=item handler example 2 |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
# given: synopsis |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
package main; |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
my $handler = $task->handler({help => 1}); |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
=back |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
=over 4 |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
=item handler example 3 |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
package Example; |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
use base 'Venus::Task'; |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
sub handler { |
903
|
|
|
|
|
|
|
my ($self, $data) = @_; |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
$self->{handler} = time; |
906
|
|
|
|
|
|
|
$self->{parsed} = $data; |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
return $self; |
909
|
|
|
|
|
|
|
} |
910
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
package main; |
912
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
my $task = Example->new; |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
my $handler = $task->handler({}); |
916
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
918
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
=back |
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
=cut |
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
=head2 header |
924
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
header() (Task) |
926
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
The header method doesn't exist on the L superclass but if defined |
928
|
|
|
|
|
|
|
returns a string that will be used as the CLI "header" (after the title, before |
929
|
|
|
|
|
|
|
the arguments, options, and commands text). |
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
I> |
932
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
=over 4 |
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
=item header example 1 |
936
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
package Example; |
938
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
use base 'Venus::Task'; |
940
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
sub header { |
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
"This text used in the header area of the usage text" |
944
|
|
|
|
|
|
|
} |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
package main; |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
my $task = Example->new; |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
my $header = $task->header; |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
# "..." |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
=back |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
=cut |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
=head2 help |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
help() (Str) |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
The help method can be overridden and returns a string representing "help" text |
963
|
|
|
|
|
|
|
for the CLI. By default this method returns the result of L, |
964
|
|
|
|
|
|
|
based on the L object. |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
I> |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
=over 4 |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
=item help example 1 |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
# given: synopsis |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
package main; |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
my $help = $task->help; |
977
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
# "Usage: application" |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
=back |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=over 4 |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
=item help example 2 |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
package Example; |
987
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
use base 'Venus::Task'; |
989
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
sub name { |
991
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
return 'eg'; |
993
|
|
|
|
|
|
|
} |
994
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
package main; |
996
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
my $task = Example->new; |
998
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
$task->prepare; |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
my $help = $task->help; |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
# "Usage: application" |
1004
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
=back |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
=cut |
1008
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
=head2 log_debug |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
log_debug(Any @log_debug) (Log) |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
The log_debug method dispatches to the L method and returns the |
1014
|
|
|
|
|
|
|
result. |
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
I> |
1017
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
=over 4 |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
=item log_debug example 1 |
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
# given: synopsis |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
package main; |
1025
|
|
|
|
|
|
|
|
1026
|
|
|
|
|
|
|
my $log_debug = $task->log_debug('something' ,'happened'); |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
# bless({...}, 'Venus::Log') |
1029
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
=back |
1031
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
=cut |
1033
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
=head2 log_error |
1035
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
log_error(Any @log_error) (Log) |
1037
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
The log_error method dispatches to the L method and returns the |
1039
|
|
|
|
|
|
|
result. |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
I> |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
=over 4 |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
=item log_error example 1 |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
# given: synopsis |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
package main; |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
my $log_error = $task->log_error('something' ,'happened'); |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
# bless({...}, 'Venus::Log') |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
=back |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
=cut |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
=head2 log_fatal |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
log_fatal(Any @log_fatal) (Log) |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
The log_fatal method dispatches to the L method and returns the |
1064
|
|
|
|
|
|
|
result. |
1065
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
I> |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
=over 4 |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
=item log_fatal example 1 |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
# given: synopsis |
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
package main; |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
my $log_fatal = $task->log_fatal('something' ,'happened'); |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
# bless({...}, 'Venus::Log') |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
=back |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=cut |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=head2 log_info |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
log_info(Any @log_info) (Log) |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
The log_info method dispatches to the L method and returns the |
1089
|
|
|
|
|
|
|
result. |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
I> |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
=over 4 |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
=item log_info example 1 |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
# given: synopsis |
1098
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
package main; |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
my $log_info = $task->log_info('something' ,'happened'); |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
# bless({...}, 'Venus::Log') |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
=back |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
=cut |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
=head2 log_level |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
log_level() (Str) |
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
The log_level method can be overridden and returns a valid L |
1114
|
|
|
|
|
|
|
value. This method defaults to returning L. |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
I> |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
=over 4 |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
=item log_level example 1 |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
# given: synopsis |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
package main; |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
my $log_level = $task->log_level; |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
# "info" |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=back |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
=cut |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
=head2 log_trace |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
log_trace(Any @log_trace) (Log) |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
The log_trace method dispatches to the L method and returns the |
1139
|
|
|
|
|
|
|
result. |
1140
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
I> |
1142
|
|
|
|
|
|
|
|
1143
|
|
|
|
|
|
|
=over 4 |
1144
|
|
|
|
|
|
|
|
1145
|
|
|
|
|
|
|
=item log_trace example 1 |
1146
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
# given: synopsis |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
package main; |
1150
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
my $log_trace = $task->log_trace('something' ,'happened'); |
1152
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
# bless({...}, 'Venus::Log') |
1154
|
|
|
|
|
|
|
|
1155
|
|
|
|
|
|
|
=back |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
=cut |
1158
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
=head2 log_warn |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
log_warn(Any @log_warn) (Log) |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
The log_warn method dispatches to the L method and returns the |
1164
|
|
|
|
|
|
|
result. |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
I> |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
=over 4 |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
=item log_warn example 1 |
1171
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
# given: synopsis |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
package main; |
1175
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
my $log_warn = $task->log_warn('something' ,'happened'); |
1177
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
# bless({...}, 'Venus::Log') |
1179
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
=back |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
=cut |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
=head2 name |
1185
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
name() (Task) |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
The name method can be overridden and returns the name of the task (and |
1189
|
|
|
|
|
|
|
application). This method defaults to C<$0> if not overridden. |
1190
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
I> |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
=over 4 |
1194
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
=item name example 1 |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
# given: synopsis |
1198
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
package main; |
1200
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
my $name = $task->name; |
1202
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
# "/path/to/application" |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
=back |
1206
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
=over 4 |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
=item name example 2 |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
package Example; |
1212
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1214
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
sub name { |
1216
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
return 'eg'; |
1218
|
|
|
|
|
|
|
} |
1219
|
|
|
|
|
|
|
|
1220
|
|
|
|
|
|
|
package main; |
1221
|
|
|
|
|
|
|
|
1222
|
|
|
|
|
|
|
my $task = Example->new; |
1223
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
my $name = $task->name; |
1225
|
|
|
|
|
|
|
|
1226
|
|
|
|
|
|
|
# "eg" |
1227
|
|
|
|
|
|
|
|
1228
|
|
|
|
|
|
|
=back |
1229
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
=cut |
1231
|
|
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
=head2 okay |
1233
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
okay(Str|CodeRef $code, Any @args) (Any) |
1235
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
The okay method exits the program with the exit code C<0>. Optionally, you can |
1237
|
|
|
|
|
|
|
dispatch before exiting by providing a method name or coderef, and arguments. |
1238
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
I> |
1240
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
=over 4 |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
=item okay example 1 |
1244
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
# given: synopsis |
1246
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
package main; |
1248
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
my $okay = $task->okay; |
1250
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
# () |
1252
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
=back |
1254
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
=over 4 |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
=item okay example 2 |
1258
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
# given: synopsis |
1260
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
package main; |
1262
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
my $okay = $task->okay('log_info', 'yatta'); |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
# () |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
=back |
1268
|
|
|
|
|
|
|
|
1269
|
|
|
|
|
|
|
=cut |
1270
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
=head2 opts |
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
opts() (HashRef) |
1274
|
|
|
|
|
|
|
|
1275
|
|
|
|
|
|
|
The opts method can be overridden and returns a hashref suitable to be passed |
1276
|
|
|
|
|
|
|
to the L method as type C<"opt">. An C<"opt"> is a CLI option |
1277
|
|
|
|
|
|
|
(or flag). |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
I> |
1280
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
=over 4 |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
=item opts example 1 |
1284
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
# given: synopsis |
1286
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
package main; |
1288
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
my $opts = $task->opts; |
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
# {} |
1292
|
|
|
|
|
|
|
|
1293
|
|
|
|
|
|
|
=back |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
=over 4 |
1296
|
|
|
|
|
|
|
|
1297
|
|
|
|
|
|
|
=item opts example 2 |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
package Example; |
1300
|
|
|
|
|
|
|
|
1301
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
sub opts { |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
return { |
1306
|
|
|
|
|
|
|
help => { |
1307
|
|
|
|
|
|
|
help => 'Display help', |
1308
|
|
|
|
|
|
|
alias => ['h'], |
1309
|
|
|
|
|
|
|
}, |
1310
|
|
|
|
|
|
|
} |
1311
|
|
|
|
|
|
|
} |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
package main; |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
my $task = Example->new; |
1316
|
|
|
|
|
|
|
|
1317
|
|
|
|
|
|
|
my $opts = $task->opts; |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
# { |
1320
|
|
|
|
|
|
|
# help => { |
1321
|
|
|
|
|
|
|
# help => 'Display help', |
1322
|
|
|
|
|
|
|
# alias => ['h'], |
1323
|
|
|
|
|
|
|
# }, |
1324
|
|
|
|
|
|
|
# } |
1325
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
=back |
1327
|
|
|
|
|
|
|
|
1328
|
|
|
|
|
|
|
=cut |
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
=head2 output |
1331
|
|
|
|
|
|
|
|
1332
|
|
|
|
|
|
|
output(Str $level, Str @messages) (Task) |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
The output method is configured as the L by L, |
1335
|
|
|
|
|
|
|
can be overridden and returns the invocant. |
1336
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
I> |
1338
|
|
|
|
|
|
|
|
1339
|
|
|
|
|
|
|
=over 4 |
1340
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
=item output example 1 |
1342
|
|
|
|
|
|
|
|
1343
|
|
|
|
|
|
|
# given: synopsis |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
package main; |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
$task->prepare; |
1348
|
|
|
|
|
|
|
|
1349
|
|
|
|
|
|
|
$task = $task->output('info', 'something happened'); |
1350
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
# bless({...}, 'Example') |
1352
|
|
|
|
|
|
|
|
1353
|
|
|
|
|
|
|
=back |
1354
|
|
|
|
|
|
|
|
1355
|
|
|
|
|
|
|
=cut |
1356
|
|
|
|
|
|
|
|
1357
|
|
|
|
|
|
|
=head2 pass |
1358
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
pass(Str|CodeRef $code, Any @args) (Any) |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
The pass method exits the program with the exit code C<0>. Optionally, you can |
1362
|
|
|
|
|
|
|
dispatch before exiting by providing a method name or coderef, and arguments. |
1363
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
I> |
1365
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
=over 4 |
1367
|
|
|
|
|
|
|
|
1368
|
|
|
|
|
|
|
=item pass example 1 |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
# given: synopsis |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
package main; |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
my $pass = $task->pass; |
1375
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
# () |
1377
|
|
|
|
|
|
|
|
1378
|
|
|
|
|
|
|
=back |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
=over 4 |
1381
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
=item pass example 2 |
1383
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
# given: synopsis |
1385
|
|
|
|
|
|
|
|
1386
|
|
|
|
|
|
|
package main; |
1387
|
|
|
|
|
|
|
|
1388
|
|
|
|
|
|
|
my $pass = $task->pass('log_info', 'yatta'); |
1389
|
|
|
|
|
|
|
|
1390
|
|
|
|
|
|
|
# () |
1391
|
|
|
|
|
|
|
|
1392
|
|
|
|
|
|
|
=back |
1393
|
|
|
|
|
|
|
|
1394
|
|
|
|
|
|
|
=cut |
1395
|
|
|
|
|
|
|
|
1396
|
|
|
|
|
|
|
=head2 prepare |
1397
|
|
|
|
|
|
|
|
1398
|
|
|
|
|
|
|
prepare() (Task) |
1399
|
|
|
|
|
|
|
|
1400
|
|
|
|
|
|
|
The prepare method can be overridden, but typically shouldn't, is responsible |
1401
|
|
|
|
|
|
|
for configuring the L and L objects, parsing the arguments, and |
1402
|
|
|
|
|
|
|
after returns the invocant. |
1403
|
|
|
|
|
|
|
|
1404
|
|
|
|
|
|
|
I> |
1405
|
|
|
|
|
|
|
|
1406
|
|
|
|
|
|
|
=over 4 |
1407
|
|
|
|
|
|
|
|
1408
|
|
|
|
|
|
|
=item prepare example 1 |
1409
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
# given: synopsis |
1411
|
|
|
|
|
|
|
|
1412
|
|
|
|
|
|
|
package main; |
1413
|
|
|
|
|
|
|
|
1414
|
|
|
|
|
|
|
my $prepare = $task->prepare; |
1415
|
|
|
|
|
|
|
|
1416
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
1417
|
|
|
|
|
|
|
|
1418
|
|
|
|
|
|
|
=back |
1419
|
|
|
|
|
|
|
|
1420
|
|
|
|
|
|
|
=over 4 |
1421
|
|
|
|
|
|
|
|
1422
|
|
|
|
|
|
|
=item prepare example 2 |
1423
|
|
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
package Example; |
1425
|
|
|
|
|
|
|
|
1426
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1427
|
|
|
|
|
|
|
|
1428
|
|
|
|
|
|
|
sub args { |
1429
|
|
|
|
|
|
|
|
1430
|
|
|
|
|
|
|
return { |
1431
|
|
|
|
|
|
|
name => { |
1432
|
|
|
|
|
|
|
help => 'Name of user', |
1433
|
|
|
|
|
|
|
}, |
1434
|
|
|
|
|
|
|
} |
1435
|
|
|
|
|
|
|
} |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
sub opts { |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
return { |
1440
|
|
|
|
|
|
|
sudo => { |
1441
|
|
|
|
|
|
|
help => 'Elevate user privileges', |
1442
|
|
|
|
|
|
|
alias => ['s'], |
1443
|
|
|
|
|
|
|
}, |
1444
|
|
|
|
|
|
|
help => { |
1445
|
|
|
|
|
|
|
help => 'Display help', |
1446
|
|
|
|
|
|
|
alias => ['h'], |
1447
|
|
|
|
|
|
|
}, |
1448
|
|
|
|
|
|
|
} |
1449
|
|
|
|
|
|
|
} |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
package main; |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
my $task = Example->new; |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
my $prepare = $task->prepare; |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
=back |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
=over 4 |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
=item prepare example 3 |
1464
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
package Example; |
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
sub args { |
1470
|
|
|
|
|
|
|
|
1471
|
|
|
|
|
|
|
return { |
1472
|
|
|
|
|
|
|
name => { |
1473
|
|
|
|
|
|
|
help => 'Name of user', |
1474
|
|
|
|
|
|
|
}, |
1475
|
|
|
|
|
|
|
} |
1476
|
|
|
|
|
|
|
} |
1477
|
|
|
|
|
|
|
|
1478
|
|
|
|
|
|
|
sub cmds { |
1479
|
|
|
|
|
|
|
|
1480
|
|
|
|
|
|
|
return { |
1481
|
|
|
|
|
|
|
admin => { |
1482
|
|
|
|
|
|
|
help => 'Run as an admin', |
1483
|
|
|
|
|
|
|
arg => 'name', |
1484
|
|
|
|
|
|
|
}, |
1485
|
|
|
|
|
|
|
user => { |
1486
|
|
|
|
|
|
|
help => 'Run as a user', |
1487
|
|
|
|
|
|
|
arg => 'name', |
1488
|
|
|
|
|
|
|
}, |
1489
|
|
|
|
|
|
|
} |
1490
|
|
|
|
|
|
|
} |
1491
|
|
|
|
|
|
|
|
1492
|
|
|
|
|
|
|
sub opts { |
1493
|
|
|
|
|
|
|
|
1494
|
|
|
|
|
|
|
return { |
1495
|
|
|
|
|
|
|
sudo => { |
1496
|
|
|
|
|
|
|
help => 'Elevate user privileges', |
1497
|
|
|
|
|
|
|
alias => ['s'], |
1498
|
|
|
|
|
|
|
}, |
1499
|
|
|
|
|
|
|
help => { |
1500
|
|
|
|
|
|
|
help => 'Display help', |
1501
|
|
|
|
|
|
|
alias => ['h'], |
1502
|
|
|
|
|
|
|
}, |
1503
|
|
|
|
|
|
|
} |
1504
|
|
|
|
|
|
|
} |
1505
|
|
|
|
|
|
|
|
1506
|
|
|
|
|
|
|
package main; |
1507
|
|
|
|
|
|
|
|
1508
|
|
|
|
|
|
|
my $task = Example->new(['admin', '-s']); |
1509
|
|
|
|
|
|
|
|
1510
|
|
|
|
|
|
|
my $prepare = $task->prepare; |
1511
|
|
|
|
|
|
|
|
1512
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
=back |
1515
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
=cut |
1517
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
=head2 run |
1519
|
|
|
|
|
|
|
|
1520
|
|
|
|
|
|
|
run(Any @args) (Task) |
1521
|
|
|
|
|
|
|
|
1522
|
|
|
|
|
|
|
The run class method will automatically execute the task class by instansiating |
1523
|
|
|
|
|
|
|
the class and calling the L method and returns the invocant. This |
1524
|
|
|
|
|
|
|
method is meant to be used directly in package scope outside of any routine, |
1525
|
|
|
|
|
|
|
and will only auto-execute under the conditions that the caller is the "main" |
1526
|
|
|
|
|
|
|
package space and the C environment variable is truthy. |
1527
|
|
|
|
|
|
|
|
1528
|
|
|
|
|
|
|
I> |
1529
|
|
|
|
|
|
|
|
1530
|
|
|
|
|
|
|
=over 4 |
1531
|
|
|
|
|
|
|
|
1532
|
|
|
|
|
|
|
=item run example 1 |
1533
|
|
|
|
|
|
|
|
1534
|
|
|
|
|
|
|
package Example; |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1537
|
|
|
|
|
|
|
|
1538
|
|
|
|
|
|
|
sub opts { |
1539
|
|
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
return { |
1541
|
|
|
|
|
|
|
help => { |
1542
|
|
|
|
|
|
|
help => 'Display help', |
1543
|
|
|
|
|
|
|
alias => ['h'], |
1544
|
|
|
|
|
|
|
}, |
1545
|
|
|
|
|
|
|
} |
1546
|
|
|
|
|
|
|
} |
1547
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
package main; |
1549
|
|
|
|
|
|
|
|
1550
|
|
|
|
|
|
|
my $task = Example->new(['--help']); |
1551
|
|
|
|
|
|
|
|
1552
|
|
|
|
|
|
|
my $run = $task->run; |
1553
|
|
|
|
|
|
|
|
1554
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
1555
|
|
|
|
|
|
|
|
1556
|
|
|
|
|
|
|
=back |
1557
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
=over 4 |
1559
|
|
|
|
|
|
|
|
1560
|
|
|
|
|
|
|
=item run example 2 |
1561
|
|
|
|
|
|
|
|
1562
|
|
|
|
|
|
|
package Example; |
1563
|
|
|
|
|
|
|
|
1564
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1565
|
|
|
|
|
|
|
|
1566
|
|
|
|
|
|
|
sub opts { |
1567
|
|
|
|
|
|
|
|
1568
|
|
|
|
|
|
|
return { |
1569
|
|
|
|
|
|
|
help => { |
1570
|
|
|
|
|
|
|
help => 'Display help', |
1571
|
|
|
|
|
|
|
alias => ['h'], |
1572
|
|
|
|
|
|
|
}, |
1573
|
|
|
|
|
|
|
} |
1574
|
|
|
|
|
|
|
} |
1575
|
|
|
|
|
|
|
|
1576
|
|
|
|
|
|
|
run Example; |
1577
|
|
|
|
|
|
|
|
1578
|
|
|
|
|
|
|
# 'Example' |
1579
|
|
|
|
|
|
|
|
1580
|
|
|
|
|
|
|
=back |
1581
|
|
|
|
|
|
|
|
1582
|
|
|
|
|
|
|
=cut |
1583
|
|
|
|
|
|
|
|
1584
|
|
|
|
|
|
|
=head2 shutdown |
1585
|
|
|
|
|
|
|
|
1586
|
|
|
|
|
|
|
shutdown(HashRef $data) (Task) |
1587
|
|
|
|
|
|
|
|
1588
|
|
|
|
|
|
|
The shutdown method can be overridden and returns the invocant. This method is |
1589
|
|
|
|
|
|
|
called by L automatically after L and is passed the result |
1590
|
|
|
|
|
|
|
of L. |
1591
|
|
|
|
|
|
|
|
1592
|
|
|
|
|
|
|
I> |
1593
|
|
|
|
|
|
|
|
1594
|
|
|
|
|
|
|
=over 4 |
1595
|
|
|
|
|
|
|
|
1596
|
|
|
|
|
|
|
=item shutdown example 1 |
1597
|
|
|
|
|
|
|
|
1598
|
|
|
|
|
|
|
# given: synopsis |
1599
|
|
|
|
|
|
|
|
1600
|
|
|
|
|
|
|
package main; |
1601
|
|
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
my $shutdown = $task->shutdown({}); |
1603
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
1605
|
|
|
|
|
|
|
|
1606
|
|
|
|
|
|
|
=back |
1607
|
|
|
|
|
|
|
|
1608
|
|
|
|
|
|
|
=cut |
1609
|
|
|
|
|
|
|
|
1610
|
|
|
|
|
|
|
=head2 startup |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
startup(HashRef $data) (Task) |
1613
|
|
|
|
|
|
|
|
1614
|
|
|
|
|
|
|
The startup method can be overridden and returns the invocant. This method is |
1615
|
|
|
|
|
|
|
called by L automatically after L and before L, |
1616
|
|
|
|
|
|
|
and is passed the result of L. |
1617
|
|
|
|
|
|
|
|
1618
|
|
|
|
|
|
|
I> |
1619
|
|
|
|
|
|
|
|
1620
|
|
|
|
|
|
|
=over 4 |
1621
|
|
|
|
|
|
|
|
1622
|
|
|
|
|
|
|
=item startup example 1 |
1623
|
|
|
|
|
|
|
|
1624
|
|
|
|
|
|
|
# given: synopsis |
1625
|
|
|
|
|
|
|
|
1626
|
|
|
|
|
|
|
package main; |
1627
|
|
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
my $startup = $task->startup({}); |
1629
|
|
|
|
|
|
|
|
1630
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
1631
|
|
|
|
|
|
|
|
1632
|
|
|
|
|
|
|
=back |
1633
|
|
|
|
|
|
|
|
1634
|
|
|
|
|
|
|
=cut |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
=head2 system |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
system(Str @args) (Task) |
1639
|
|
|
|
|
|
|
|
1640
|
|
|
|
|
|
|
The system method attempts to make a L call and returns the |
1641
|
|
|
|
|
|
|
invocant. If the system call is unsuccessful an error is thrown. |
1642
|
|
|
|
|
|
|
|
1643
|
|
|
|
|
|
|
I> |
1644
|
|
|
|
|
|
|
|
1645
|
|
|
|
|
|
|
=over 4 |
1646
|
|
|
|
|
|
|
|
1647
|
|
|
|
|
|
|
=item system example 1 |
1648
|
|
|
|
|
|
|
|
1649
|
|
|
|
|
|
|
# given: synopsis |
1650
|
|
|
|
|
|
|
|
1651
|
|
|
|
|
|
|
package main; |
1652
|
|
|
|
|
|
|
|
1653
|
|
|
|
|
|
|
my $system = $task->system($^X, '-V'); |
1654
|
|
|
|
|
|
|
|
1655
|
|
|
|
|
|
|
# bless({...}, 'Example') |
1656
|
|
|
|
|
|
|
|
1657
|
|
|
|
|
|
|
=back |
1658
|
|
|
|
|
|
|
|
1659
|
|
|
|
|
|
|
=over 4 |
1660
|
|
|
|
|
|
|
|
1661
|
|
|
|
|
|
|
=item system example 2 |
1662
|
|
|
|
|
|
|
|
1663
|
|
|
|
|
|
|
# given: synopsis |
1664
|
|
|
|
|
|
|
|
1665
|
|
|
|
|
|
|
package main; |
1666
|
|
|
|
|
|
|
|
1667
|
|
|
|
|
|
|
my $system = $task->system('/path/to/nowhere'); |
1668
|
|
|
|
|
|
|
|
1669
|
|
|
|
|
|
|
# Exception! (isa Example::Error) (see error_on_system_call) |
1670
|
|
|
|
|
|
|
|
1671
|
|
|
|
|
|
|
=back |
1672
|
|
|
|
|
|
|
|
1673
|
|
|
|
|
|
|
=cut |
1674
|
|
|
|
|
|
|
|
1675
|
|
|
|
|
|
|
=head2 test |
1676
|
|
|
|
|
|
|
|
1677
|
|
|
|
|
|
|
test(Str $type, Str $name) (Any) |
1678
|
|
|
|
|
|
|
|
1679
|
|
|
|
|
|
|
The test method validates the values for the C or C specified and |
1680
|
|
|
|
|
|
|
returns the value(s) associated. This method dispatches to L. |
1681
|
|
|
|
|
|
|
|
1682
|
|
|
|
|
|
|
I> |
1683
|
|
|
|
|
|
|
|
1684
|
|
|
|
|
|
|
=over 4 |
1685
|
|
|
|
|
|
|
|
1686
|
|
|
|
|
|
|
=item test example 1 |
1687
|
|
|
|
|
|
|
|
1688
|
|
|
|
|
|
|
package Example; |
1689
|
|
|
|
|
|
|
|
1690
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1691
|
|
|
|
|
|
|
|
1692
|
|
|
|
|
|
|
sub opts { |
1693
|
|
|
|
|
|
|
|
1694
|
|
|
|
|
|
|
return { |
1695
|
|
|
|
|
|
|
help => { |
1696
|
|
|
|
|
|
|
help => 'Display help', |
1697
|
|
|
|
|
|
|
alias => ['h'], |
1698
|
|
|
|
|
|
|
}, |
1699
|
|
|
|
|
|
|
} |
1700
|
|
|
|
|
|
|
} |
1701
|
|
|
|
|
|
|
|
1702
|
|
|
|
|
|
|
package main; |
1703
|
|
|
|
|
|
|
|
1704
|
|
|
|
|
|
|
my $task = Example->new(['--help']); |
1705
|
|
|
|
|
|
|
|
1706
|
|
|
|
|
|
|
my ($help) = $task->prepare->test('opt', 'help'); |
1707
|
|
|
|
|
|
|
|
1708
|
|
|
|
|
|
|
# true |
1709
|
|
|
|
|
|
|
|
1710
|
|
|
|
|
|
|
=back |
1711
|
|
|
|
|
|
|
|
1712
|
|
|
|
|
|
|
=over 4 |
1713
|
|
|
|
|
|
|
|
1714
|
|
|
|
|
|
|
=item test example 2 |
1715
|
|
|
|
|
|
|
|
1716
|
|
|
|
|
|
|
package Example; |
1717
|
|
|
|
|
|
|
|
1718
|
|
|
|
|
|
|
use base 'Venus::Task'; |
1719
|
|
|
|
|
|
|
|
1720
|
|
|
|
|
|
|
sub opts { |
1721
|
|
|
|
|
|
|
|
1722
|
|
|
|
|
|
|
return { |
1723
|
|
|
|
|
|
|
help => { |
1724
|
|
|
|
|
|
|
type => 'string', |
1725
|
|
|
|
|
|
|
help => 'Display help', |
1726
|
|
|
|
|
|
|
alias => ['h'], |
1727
|
|
|
|
|
|
|
}, |
1728
|
|
|
|
|
|
|
} |
1729
|
|
|
|
|
|
|
} |
1730
|
|
|
|
|
|
|
|
1731
|
|
|
|
|
|
|
package main; |
1732
|
|
|
|
|
|
|
|
1733
|
|
|
|
|
|
|
my $task = Example->new(['--help']); |
1734
|
|
|
|
|
|
|
|
1735
|
|
|
|
|
|
|
my ($help) = $task->prepare->test('opt', 'help'); |
1736
|
|
|
|
|
|
|
|
1737
|
|
|
|
|
|
|
# Exception! (isa Venus::Cli::Error) (see error_on_arg_validation) |
1738
|
|
|
|
|
|
|
|
1739
|
|
|
|
|
|
|
# Invalid option: help: received (undef), expected (string) |
1740
|
|
|
|
|
|
|
|
1741
|
|
|
|
|
|
|
=back |
1742
|
|
|
|
|
|
|
|
1743
|
|
|
|
|
|
|
=cut |
1744
|
|
|
|
|
|
|
|
1745
|
|
|
|
|
|
|
=head2 usage |
1746
|
|
|
|
|
|
|
|
1747
|
|
|
|
|
|
|
usage() (Task) |
1748
|
|
|
|
|
|
|
|
1749
|
|
|
|
|
|
|
The usage method exits the program with the exit code C<1> after calling |
1750
|
|
|
|
|
|
|
L with the result of L. This method makes it easy to output |
1751
|
|
|
|
|
|
|
the default help text and end the program if some condition isn't met. |
1752
|
|
|
|
|
|
|
|
1753
|
|
|
|
|
|
|
I> |
1754
|
|
|
|
|
|
|
|
1755
|
|
|
|
|
|
|
=over 4 |
1756
|
|
|
|
|
|
|
|
1757
|
|
|
|
|
|
|
=item usage example 1 |
1758
|
|
|
|
|
|
|
|
1759
|
|
|
|
|
|
|
# given: synopsis |
1760
|
|
|
|
|
|
|
|
1761
|
|
|
|
|
|
|
package main; |
1762
|
|
|
|
|
|
|
|
1763
|
|
|
|
|
|
|
my $usage = $task->usage; |
1764
|
|
|
|
|
|
|
|
1765
|
|
|
|
|
|
|
# bless({...}, 'Venus::Task') |
1766
|
|
|
|
|
|
|
|
1767
|
|
|
|
|
|
|
=back |
1768
|
|
|
|
|
|
|
|
1769
|
|
|
|
|
|
|
=cut |
1770
|
|
|
|
|
|
|
|
1771
|
|
|
|
|
|
|
=head1 ERRORS |
1772
|
|
|
|
|
|
|
|
1773
|
|
|
|
|
|
|
This package may raise the following errors: |
1774
|
|
|
|
|
|
|
|
1775
|
|
|
|
|
|
|
=cut |
1776
|
|
|
|
|
|
|
|
1777
|
|
|
|
|
|
|
=over 4 |
1778
|
|
|
|
|
|
|
|
1779
|
|
|
|
|
|
|
=item error: C |
1780
|
|
|
|
|
|
|
|
1781
|
|
|
|
|
|
|
This package may raise an error_on_system_call exception. |
1782
|
|
|
|
|
|
|
|
1783
|
|
|
|
|
|
|
B |
1784
|
|
|
|
|
|
|
|
1785
|
|
|
|
|
|
|
# given: synopsis; |
1786
|
|
|
|
|
|
|
|
1787
|
|
|
|
|
|
|
my @args = (['/path/to/nowhere', 'arg1', 'arg2'], $?); |
1788
|
|
|
|
|
|
|
|
1789
|
|
|
|
|
|
|
my $error = $task->throw('error_on_system_call', @args)->catch('error'); |
1790
|
|
|
|
|
|
|
|
1791
|
|
|
|
|
|
|
# my $name = $error->name; |
1792
|
|
|
|
|
|
|
|
1793
|
|
|
|
|
|
|
# "on_system_call" |
1794
|
|
|
|
|
|
|
|
1795
|
|
|
|
|
|
|
# my $message = $error->message; |
1796
|
|
|
|
|
|
|
|
1797
|
|
|
|
|
|
|
# "Can't make system call \"/path/to/nowhere arg1 arg2\": $?" |
1798
|
|
|
|
|
|
|
|
1799
|
|
|
|
|
|
|
# my $args = $error->stash('args'); |
1800
|
|
|
|
|
|
|
|
1801
|
|
|
|
|
|
|
# [] |
1802
|
|
|
|
|
|
|
|
1803
|
|
|
|
|
|
|
=back |
1804
|
|
|
|
|
|
|
|
1805
|
|
|
|
|
|
|
=head1 AUTHORS |
1806
|
|
|
|
|
|
|
|
1807
|
|
|
|
|
|
|
Awncorp, C |
1808
|
|
|
|
|
|
|
|
1809
|
|
|
|
|
|
|
=cut |
1810
|
|
|
|
|
|
|
|
1811
|
|
|
|
|
|
|
=head1 LICENSE |
1812
|
|
|
|
|
|
|
|
1813
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
1814
|
|
|
|
|
|
|
|
1815
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
1816
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
1817
|
|
|
|
|
|
|
|
1818
|
|
|
|
|
|
|
=cut |