| 1 | package CPANPLUS; | ||||||||||
| 2 | |||||||||||
| 3 | 20 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 20 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 20 | ▶ | use CPANPLUS::Error; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 20 | ▶ | use CPANPLUS::Backend; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 20 | ▶ | use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | BEGIN { | ||||||||||
| 12 | 20 | ▶ | use Exporter (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 20 | ▶ | use vars qw( @EXPORT @ISA $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 20 | ▶ | @EXPORT = qw( shell fetch get install ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 20 | @ISA = qw( Exporter ); | |||||||||
| 16 | 20 | $VERSION = "0.9912"; #have to hardcode or cpan.org gets unhappy | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | ### purely for backward compatibility, so we can call it from the commandline: | ||||||||||
| 20 | ### perl -MCPANPLUS -e 'install Net::SMTP' | ||||||||||
| 21 | sub install { | ||||||||||
| 22 | 4 | ▶ | my $cpan = CPANPLUS::Backend->new; | ||||||||
|
Subroutine
install: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 23 | 4 | ▶ | my $mod = shift or ( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | error(loc("No module specified!")), return | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 3 | ▶ | if ( ref $mod ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 1 | error( loc( "You passed an object. Use %1 for OO style interaction", | |||||||||
| 29 | 'CPANPLUS::Backend' )); | ||||||||||
| 30 | 1 | return; | |||||||||
| 31 | |||||||||||
| 32 | } else { | ||||||||||
| 33 | 2 | ▶ | my $obj = $cpan->module_tree($mod) or ( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | error(loc("No such module '%1'", $mod)), | ||||||||||
| 35 | return | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 2 | my $ok = $obj->install; | |||||||||
| 39 | |||||||||||
| 40 | 2 | ▶ | $ok | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | ? msg(loc("Installing of %1 successful", $mod),1) | ||||||||||
| 42 | : msg(loc("Installing of %1 failed", $mod),1); | ||||||||||
| 43 | |||||||||||
| 44 | 2 | return $ok; | |||||||||
| 45 | } | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | ### simply downloads a module and stores it | ||||||||||
| 49 | sub fetch { | ||||||||||
| 50 | 8 | ▶ | my $cpan = CPANPLUS::Backend->new; | ||||||||
|
Subroutine
fetch: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 8 | ▶ | my $mod = shift or ( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | error(loc("No module specified!")), return | ||||||||||
| 54 | ); | ||||||||||
| 55 | |||||||||||
| 56 | 6 | ▶ | if ( ref $mod ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 2 | error( loc( "You passed an object. Use %1 for OO style interaction", | |||||||||
| 58 | 'CPANPLUS::Backend' )); | ||||||||||
| 59 | 2 | return; | |||||||||
| 60 | |||||||||||
| 61 | } else { | ||||||||||
| 62 | 4 | ▶ | my $obj = $cpan->module_tree($mod) or ( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | error(loc("No such module '%1'", $mod)), | ||||||||||
| 64 | return | ||||||||||
| 65 | ); | ||||||||||
| 66 | |||||||||||
| 67 | 4 | my $ok = $obj->fetch( fetchdir => '.' ); | |||||||||
| 68 | |||||||||||
| 69 | 4 | ▶ | $ok | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | ? msg(loc("Fetching of %1 successful", $mod),1) | ||||||||||
| 71 | : msg(loc("Fetching of %1 failed", $mod),1); | ||||||||||
| 72 | |||||||||||
| 73 | 4 | return $ok; | |||||||||
| 74 | } | ||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | ### alias to fetch() due to compatibility with cpan.pm ### | ||||||||||
| 78 | 4 | ▶ | sub get { fetch(@_) } | ||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 79 | |||||||||||
| 80 | |||||||||||
| 81 | ### purely for backwards compatibility, so we can call it from the commandline: | ||||||||||
| 82 | ### perl -MCPANPLUS -e 'shell' | ||||||||||
| 83 | sub shell { | ||||||||||
| 84 | 1 | ▶ | my $option = shift; | ||||||||
|
Subroutine
shell: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 85 | |||||||||||
| 86 | ### since the user can specify the type of shell they wish to start | ||||||||||
| 87 | ### when they call the shell() function, we have to eval the usage | ||||||||||
| 88 | ### of CPANPLUS::Shell so we can set up all the checks properly | ||||||||||
| 89 | 1 | eval { require CPANPLUS::Shell; CPANPLUS::Shell->import($option) }; | |||||||||
| 90 | 1 | ▶ | die $@ if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | |||||||||||
| 92 | 1 | my $cpan = CPANPLUS::Shell->new(); | |||||||||
| 93 | |||||||||||
| 94 | 1 | $cpan->shell(); | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 20 | 1; | |||||||||
| 98 | |||||||||||
| 99 | __END__ | ||||||||||