line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Version::App; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:XSAWYERX'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Application implementation for Module::Version |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1590
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp qw< croak >; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
771
|
use Getopt::Long qw( :config no_ignore_case ); |
|
1
|
|
|
|
|
10516
|
|
|
1
|
|
|
|
|
4
|
|
10
|
1
|
|
|
1
|
|
646
|
use Module::Version 'get_version'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
616
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
1
|
612
|
sub new { return bless {}, $_[0] } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub run { |
17
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
18
|
0
|
|
|
|
|
0
|
my @modules; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
$self->parse_opts; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$self->{'modules'} |
23
|
0
|
0
|
|
|
|
0
|
and push @modules, @{ $self->{'modules'} }; |
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
0
|
if ( my $file = $self->{'input'} ) { |
26
|
0
|
0
|
|
|
|
0
|
open my $fh, '<', $file |
27
|
|
|
|
|
|
|
or croak("Cannot open '$file': $!"); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
chomp( my @extra_modules = <$fh> ); |
30
|
0
|
|
|
|
|
0
|
push @modules, @extra_modules; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
0
|
close $fh |
33
|
|
|
|
|
|
|
or croak("Cannot close '$file': $!"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
0
|
if ( $self->{'include'} ) { |
37
|
0
|
|
|
|
|
0
|
my $include = $self->{'include'}; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
0
|
ref $include eq 'ARRAY' |
40
|
|
|
|
|
|
|
or die "Error: include must be an ARRAY ref\n"; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
unshift @INC, @{$include}; |
|
0
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
@modules |
46
|
0
|
0
|
|
|
|
0
|
or die "Error: no modules to check\n"; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
foreach my $module (@modules) { |
49
|
0
|
|
|
|
|
0
|
my $version = get_version($module); |
50
|
0
|
0
|
|
|
|
0
|
if ( !$version ) { |
51
|
0
|
0
|
|
|
|
0
|
$self->{'quiet'} |
52
|
|
|
|
|
|
|
or warn "Warning: module '$module' does not seem to be installed.\n"; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
next; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
0
|
$self->{'dev'} or $version =~ s/_(.+)$/$1/xms; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
0
|
my $output = $self->{'full'} ? "$module $version\n" : "$version\n"; |
60
|
0
|
|
|
|
|
0
|
print $output; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub parse_opts { |
65
|
3
|
|
|
3
|
1
|
1149
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
GetOptions( |
68
|
1
|
|
|
1
|
|
755
|
'h|help' => sub { $self->help }, |
69
|
|
|
|
|
|
|
'f|full!' => \$self->{'full'}, |
70
|
|
|
|
|
|
|
'i|input=s' => \$self->{'input'}, |
71
|
|
|
|
|
|
|
'I|include=s@' => \$self->{'include'}, |
72
|
|
|
|
|
|
|
'd|dev!' => \$self->{'dev'}, |
73
|
|
|
|
|
|
|
'q|quiet!' => \$self->{'quiet'}, |
74
|
1
|
|
|
1
|
|
460
|
'<>' => sub { $self->process(@_) }, |
75
|
3
|
100
|
|
|
|
26
|
) or $self->error('could not parse options'); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub process { |
79
|
|
|
|
|
|
|
my ( $self, @args ) = @_; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# force stringify Getopt::Long input |
82
|
|
|
|
|
|
|
push @{ $self->{'modules'} }, "$_" for @args; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub help { |
86
|
|
|
|
|
|
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
print << "_END_HEREDOC"; |
89
|
|
|
|
|
|
|
$0 [ OPTIONS ] Module Module Module... |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Provide a module's version, comfortably. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
OPTIONS |
94
|
|
|
|
|
|
|
-f | --full Output name and version (a la Module::Version 0.05) |
95
|
|
|
|
|
|
|
-I | --include Include any number of directories to include as well |
96
|
|
|
|
|
|
|
-i | --input Input file to read module names from |
97
|
|
|
|
|
|
|
-d | --dev Show developer versions as 0.01_01 instead of 0.0101 |
98
|
|
|
|
|
|
|
-q | --quiet Do not error out if module doesn't exist |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
_END_HEREDOC |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |