2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
5 # $Id: cpan,v 1.3 2002/08/30 08:55:15 k Exp $
10 cpan - easily interact with CPAN from the command line
14 # with arguments, installs specified modules
15 cpan module_name [ module_name ... ]
17 # with switches, installs modules with extra behavior
18 cpan [-cimt] module_name [ module_name ... ]
20 # without arguments, starts CPAN shell
23 # without arguments, but some switches
28 This script provides a command interface (not a shell) to CPAN.pm.
32 These options are mutually exclusive, and the script processes
33 them in this order: [ahvr]. Once the script finds one, it ignores
34 the others, and then exits after it finishes the task. The script
35 ignores any other command line options.
41 Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.
45 Prints a help message.
49 Recompiles dynamically loaded modules with CPAN::Shell->recompile.
53 Print the script version and CPAN.pm version.
59 These options are mutually exclusive, and the script processes
60 them in alphabetical order.
66 Runs a `make clean` in the specified module's directories.
70 Installed the specified modules.
74 Makes the specified modules.
78 Runs a `make test` on the specified modules.
84 # print a help message
87 # print the version numbers
90 # create an autobundle
97 cpan -i Netscape::Booksmarks Business::ISBN
101 * add options for other CPAN::Shell functions
102 autobundle, clean, make, recompile, test
110 Most behaviour, including environment variables and configuration,
111 comes directly from CPAN.pm.
115 brian d foy <bdfoy@cpan.org>
123 sprintf "%d.%02d", q
$Revision: 1.3 $ =~ m/ (\d+) \. (\d+) /xg;
125 my $Default = 'default';
127 my $META_OPTIONS = 'ahvr';
130 $Default => 'install',
137 my @cpan_options = grep { $_ ne $Default } sort keys %CPAN_METHODS;
139 my $arg_count = @ARGV;
142 Getopt
::Std
::getopts
(
143 join( '', @cpan_options, $META_OPTIONS ), \
%options );
147 print STDERR
"Printing help message -- ignoring other arguments\n"
150 print STDERR
"Use perldoc to read the documentation\n";
155 print STDERR
"Printing version message -- ignoring other arguments\n"
159 my $CPAN_VERSION = CPAN
->VERSION;
160 print STDERR
"cpan script version $VERSION\n" .
161 "CPAN.pm version $CPAN_VERSION\n";
166 print "Creating autobundle in ", $CPAN::Config
->{cpan_home
},
168 print STDERR
"Creating autobundle -- ignoring other arguments\n"
171 CPAN
::Shell
->autobundle;
176 print STDERR
"Creating autobundle -- ignoring other arguments\n"
179 CPAN
::Shell
->recompile;
185 foreach my $option ( @cpan_options )
187 next unless $options{$option};
192 if( not $switch and @ARGV ) { $switch = $Default; }
193 elsif( not $switch and not @ARGV ) { CPAN
::shell
(); exit 0; }
194 elsif( $switch and not @ARGV )
195 { die "Nothing to $CPAN_METHODS{$switch}!\n"; }
197 my $method = $CPAN_METHODS{$switch};
198 die "CPAN.pm cannot $method!\n" unless CPAN
::Shell
->can( $method );
200 foreach my $arg ( @ARGV )
202 CPAN
::Shell
->$method( $arg );