File Coverage

blib/lib/App/CPAN/Search.pm
Criterion Covered Total %
statement 23 26 88.4
branch 1 2 50.0
condition 5 6 83.3
subroutine 6 6 100.0
pod 2 2 100.0
total 37 42 88.1


line stmt bran cond sub pod time code
1             package App::CPAN::Search;
2              
3 4     4   126212 use strict;
  4         8  
  4         218  
4 4     4   34 use warnings;
  4         8  
  4         189  
5              
6 4     4   4054 use CPAN;
  4         1497288  
  4         1865  
7 4     4   3492 use Getopt::Std;
  4         11371  
  4         1625  
8              
9             our $VERSION = 0.11;
10              
11             # Constructor.
12             sub new {
13 4     4 1 904427 my ($class, @params) = @_;
14              
15             # Create object.
16 4         14 my $self = bless {}, $class;
17              
18             # Object.
19 4         22 return $self;
20             }
21              
22             # Run.
23             sub run {
24 3     3 1 8 my $self = shift;
25              
26             # Process arguments.
27 3         18 $self->{'_opts'} = {
28             'h' => 0,
29             };
30 3 50 100     18 if (! getopts('h', $self->{'_opts'})
      66        
31             || $self->{'_opts'}->{'h'}
32             || @ARGV < 1) {
33              
34 3         406 print STDERR "Usage: $0 [-h] [--version] module_prefix\n";
35 3         101 print STDERR "\t-h\t\tPrint help.\n";
36 3         54 print STDERR "\t--version\tPrint version.\n";
37 3         38 print STDERR "\tmodule_prefix\tModule prefix. e.g. ".
38             "Module::Install\n";
39 3         22 return 1;
40             }
41 0           $self->{'_module_prefix'} = shift @ARGV;
42              
43             # Print all modules with prefix.
44             # XXX Rewrite to something nice.
45 0           CPAN::Shell->m("/^$self->{'_module_prefix'}/");
46              
47 0           return 0;
48             }
49              
50             1;
51              
52             __END__