bin/mpath

filter: Statementstmt 93.5% 29 / 31 Branchbran 78.5% 11 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 90.2% 46 / 51 CC 1 SCAR 0.0
CC
1
Cov
89%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Module/Path.pm ↑ Summary
1 #!/usr/bin/env perl
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Module::Path qw(module_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Getopt::Long qw(GetOptions);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use Pod::Usage qw(pod2usage);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶GetOptions(\my %opts, 'help|h|?', 'quiet|q', 'full|f')
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions(\my %opts, "help|h|?", "quiet|q", "full|f") or pod2usage(2) 6 0 6
10 or pod2usage 2;
11  
12 6 ▶if ($opts{help}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts{'help'}) { } 0 6 6
elsif (not @ARGV) { } 0 6 6
13 0 pod2usage(
14 -verbose => 2,
15 -exitval => 0,
16 )
17 }
18 elsif (!@ARGV) {
19 0 pod2usage(
20 -message => 'No module specified',
21 -verbose => 1,
22 );
23 }
24  
25 6 my $all_found = 1;
26  
27 6 for my $module (@ARGV) {
28 12 my $path = module_path($module);
29 12 ▶ if (!defined($path)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $path) { } 3 9 12
30 3 $all_found = 0;
31 3 ▶ print "$module not found\n" unless $opts{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"quiet"} 2 1 3
32 }
33 else {
34 9 ▶ print "$module " if $opts{full};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"full"} 2 7 9
35 9 print "$path\n";
36 }
37 }
38  
39 6 ▶my $status = $all_found ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$all_found ? : 3 3 6
40 6 exit $status;
41  
42 =head1 NAME
43  
44 mpath - display the full path to a perl module (installed locally)
45  
46 =head1 USAGE
47  
48 mpath [OPTIONS] MODULE [MODULE ...]
49  
50 =head1 EXAMPLE
51  
52 % mpath Module::Path
53 /usr/local/lib/perl5/site_perl/5.16.0/Module/Path.pm
54  
55 % mpath --full Module::Path
56 Module::Path /usr/local/lib/perl5/site_perl/5.16.0/Module/Path.pm
57  
58 % mpath Moose Moo
59 /usr/local/lib/perl5/site_perl/5.16.0/darwin-2level/Moose.pm
60 /usr/local/lib/perl5/site_perl/5.16.0/Moo.pm
61  
62 =head1 DESCRIPTION
63  
64 mpath displays the full path to a perl module on the local system.
65 It uses the C<module_path()> function from L<Module::Path> to get the path.
66  
67 If one of the module wasn't found, mpath will exit with the exit code 1 and
68 print the following message (you can silence it with the option B<--quiet>):
69  
70 % mpath Foo::Bar
71 Foo::Bar not found
72  
73 or:
74  
75 % mpath Moose Foo::Bar
76 /usr/local/lib/perl5/site_perl/5.16.0/darwin-2level/Moose.pm
77 Foo::Bar not found
78  
79 =head1 OPTIONS
80  
81 =over
82  
83 =item B<-h>, B<-?>, B<--help>
84  
85 Print this help message and exit.
86  
87 =item B<-f>, B<--full>
88  
89 Print module name.
90  
91 =item B<-q>, B<--quiet>
92  
93 Don't print any error when one of the module requested could not be found.
94  
95 =back
96  
97 =head1 SEE ALSO
98  
99 L<Module::Path>
100  
101 =head1 AUTHOR
102  
103 Neil Bowers E<lt>neilb@cpan.orgE<gt>
104  
105 =head1 COPYRIGHT AND LICENSE
106  
107 This software is copyright (c) 2012 by Neil Bowers E<lt>neilb@cpan.orgE<gt>.
108  
109 This is free software; you can redistribute it and/or modify it under
110 the same terms as the Perl 5 programming language system itself.
« blib/lib/Module/Path.pm ↑ Summary