line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::CLI::Command::Version; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
763
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw/App::CLI::Command/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
182
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
App::CLI::Command::Version - Print a preformatted version string |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package MyApp; |
15
|
|
|
|
|
|
|
use base qw(App::CLI App::CLI::Command); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use constant alias => ( |
18
|
|
|
|
|
|
|
'--version' => '+App::CLI::Command::Version', |
19
|
|
|
|
|
|
|
'version' => '+App::CLI::Command::Version', |
20
|
|
|
|
|
|
|
# Other aliases |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Your app now supports a default version command and option |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This is package provides a default C command modelled after |
28
|
|
|
|
|
|
|
that of L. You can modify the default message by subclassing |
29
|
|
|
|
|
|
|
this command and overriding its C method, or by modifying it with |
30
|
|
|
|
|
|
|
eg. L. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub run { |
35
|
2
|
|
|
2
|
0
|
4
|
my ($self) = shift; |
36
|
1
|
|
|
1
|
|
8
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
103
|
|
37
|
2
|
|
|
|
|
8
|
print sprintf "%s (%s) version %s (%s)\n", |
38
|
|
|
|
|
|
|
$self->app->prog_name, ref $self->app, $self->app->VERSION, $0; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |