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>
119 my $VERSION = sprintf "%.3f", 1.2 + substr(q$Rev: 228 $,4)/1000;
121 my $Default = 'default';
123 my $META_OPTIONS = 'ahvr';
126 $Default => 'install',
133 my @cpan_options = grep { $_ ne $Default } sort keys %CPAN_METHODS;
135 my $arg_count = @ARGV;
138 Getopt::Std::getopts(
139 join( '', @cpan_options, $META_OPTIONS ), \%options );
143 print STDERR "Printing help message -- ignoring other arguments\n"
146 print STDERR "Use perldoc to read the documentation\n";
151 print STDERR "Printing version message -- ignoring other arguments\n"
155 my $CPAN_VERSION = CPAN->VERSION;
156 print STDERR "cpan script version $VERSION\n" .
157 "CPAN.pm version $CPAN_VERSION\n";
162 print "Creating autobundle in ", $CPAN::Config->{cpan_home},
164 print STDERR "Creating autobundle -- ignoring other arguments\n"
167 CPAN::Shell->autobundle;
172 print STDERR "Creating autobundle -- ignoring other arguments\n"
175 CPAN::Shell->recompile;
181 foreach my $option ( @cpan_options )
183 next unless $options{$option};
188 if( not $switch and @ARGV ) { $switch = $Default; }
189 elsif( not $switch and not @ARGV ) { CPAN::shell(); exit 0; }
190 elsif( $switch and not @ARGV )
191 { die "Nothing to $CPAN_METHODS{$switch}!\n"; }
193 my $method = $CPAN_METHODS{$switch};
194 die "CPAN.pm cannot $method!\n" unless CPAN::Shell->can( $method );
196 foreach my $arg ( @ARGV )
198 CPAN::Shell->$method( $arg );