2 # $Id: cpan,v 1.3 2002/08/30 08:55:15 k Exp $
7 cpan - easily interact with CPAN from the command line
11 # with arguments, installs specified modules
12 cpan module_name [ module_name ... ]
14 # with switches, installs modules with extra behavior
15 cpan [-cimt] module_name [ module_name ... ]
17 # without arguments, starts CPAN shell
20 # without arguments, but some switches
25 This script provides a command interface (not a shell) to CPAN.pm.
29 These options are mutually exclusive, and the script processes
30 them in this order: [ahvr]. Once the script finds one, it ignores
31 the others, and then exits after it finishes the task. The script
32 ignores any other command line options.
38 Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.
42 Prints a help message.
46 Recompiles dynamically loaded modules with CPAN::Shell->recompile.
50 Print the script version and CPAN.pm version.
56 These options are mutually exclusive, and the script processes
57 them in alphabetical order.
63 Runs a `make clean` in the specified module's directories.
67 Installed the specified modules.
71 Makes the specified modules.
75 Runs a `make test` on the specified modules.
81 # print a help message
84 # print the version numbers
87 # create an autobundle
94 cpan -i Netscape::Booksmarks Business::ISBN
98 * add options for other CPAN::Shell functions
99 autobundle, clean, make, recompile, test
107 Most behaviour, including environment variables and configuration,
108 comes directly from CPAN.pm.
112 brian d foy <bdfoy@cpan.org>
120 sprintf "%d.%02d", q$Revision: 1.3 $ =~ m/ (\d+) \. (\d+) /xg;
122 my $Default = 'default';
124 my $META_OPTIONS = 'ahvr';
127 $Default => 'install',
134 my @cpan_options = grep { $_ ne $Default } sort keys %CPAN_METHODS;
136 my $arg_count = @ARGV;
139 Getopt::Std::getopts(
140 join( '', @cpan_options, $META_OPTIONS ), \%options );
144 print STDERR "Printing help message -- ignoring other arguments\n"
147 print STDERR "Use perldoc to read the documentation\n";
152 print STDERR "Printing version message -- ignoring other arguments\n"
156 my $CPAN_VERSION = CPAN->VERSION;
157 print STDERR "cpan script version $VERSION\n" .
158 "CPAN.pm version $CPAN_VERSION\n";
163 print "Creating autobundle in ", $CPAN::Config->{cpan_home},
165 print STDERR "Creating autobundle -- ignoring other arguments\n"
168 CPAN::Shell->autobundle;
173 print STDERR "Creating autobundle -- ignoring other arguments\n"
176 CPAN::Shell->recompile;
182 foreach my $option ( @cpan_options )
184 next unless $options{$option};
189 if( not $switch and @ARGV ) { $switch = $Default; }
190 elsif( not $switch and not @ARGV ) { CPAN::shell(); exit 0; }
191 elsif( $switch and not @ARGV )
192 { die "Nothing to $CPAN_METHODS{$switch}!\n"; }
194 my $method = $CPAN_METHODS{$switch};
195 die "CPAN.pm cannot $method!\n" unless CPAN::Shell->can( $method );
197 foreach my $arg ( @ARGV )
199 CPAN::Shell->$method( $arg );