source: other-projects/trunk/realistic-books/bin/windows/perl/bin/cpan.bat@ 19631

Last change on this file since 19631 was 19631, checked in by davidb, 15 years ago

addition of bin directory

  • Property svn:executable set to *
File size: 4.2 KB
Line 
1@rem = '--*-Perl-*--
2@echo off
3if "%OS%" == "Windows_NT" goto WinNT
4perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
5goto endofperl
6:WinNT
7perl -x -S %0 %*
8if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
9if %errorlevel% == 9009 echo You do not have Perl in your PATH.
10if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
11goto endofperl
12@rem ';
13#!perl
14#line 15
15 eval 'exec c:\shaoqunWu\perl\bin\perl.exe -S $0 ${1+"$@"}'
16 if $running_under_some_shell;
17#!/usr/bin/perl
18# $Id: cpan,v 1.3 2002/08/30 08:55:15 k Exp $
19use strict;
20
21=head1 NAME
22
23cpan - easily interact with CPAN from the command line
24
25=head1 SYNOPSIS
26
27 # with arguments, installs specified modules
28 cpan module_name [ module_name ... ]
29
30 # with switches, installs modules with extra behavior
31 cpan [-cimt] module_name [ module_name ... ]
32
33 # without arguments, starts CPAN shell
34 cpan
35
36 # without arguments, but some switches
37 cpan [-ahrv]
38
39=head1 DESCRIPTION
40
41This script provides a command interface (not a shell) to CPAN.pm.
42
43=head2 Meta Options
44
45These options are mutually exclusive, and the script processes
46them in this order: [ahvr]. Once the script finds one, it ignores
47the others, and then exits after it finishes the task. The script
48ignores any other command line options.
49
50=over 4
51
52=item -a
53
54Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.
55
56=item -h
57
58Prints a help message.
59
60=item -r
61
62Recompiles dynamically loaded modules with CPAN::Shell->recompile.
63
64=item -v
65
66Print the script version and CPAN.pm version.
67
68=back
69
70=head2 Module options
71
72These options are mutually exclusive, and the script processes
73them in alphabetical order.
74
75=over 4
76
77=item c
78
79Runs a `make clean` in the specified module's directories.
80
81=item i
82
83Installed the specified modules.
84
85=item m
86
87Makes the specified modules.
88
89=item t
90
91Runs a `make test` on the specified modules.
92
93=back
94
95=head2 Examples
96
97 # print a help message
98 cpan -h
99
100 # print the version numbers
101 cpan -v
102
103 # create an autobundle
104 cpan -a
105
106 # recompile modules
107 cpan -r
108
109 # install modules
110 cpan -i Netscape::Booksmarks Business::ISBN
111
112=head1 TO DO
113
114* add options for other CPAN::Shell functions
115autobundle, clean, make, recompile, test
116
117=head1 BUGS
118
119* none noted
120
121=head1 SEE ALSO
122
123Most behaviour, including environment variables and configuration,
124comes directly from CPAN.pm.
125
126=head1 AUTHOR
127
128brian d foy <[email protected]>
129
130=cut
131
132use CPAN ();
133use Getopt::Std;
134
135my $VERSION =
136 sprintf "%d.%02d", q$Revision: 1.3 $ =~ m/ (\d+) \. (\d+) /xg;
137
138my $Default = 'default';
139
140my $META_OPTIONS = 'ahvr';
141
142my %CPAN_METHODS = (
143 $Default => 'install',
144 'c' => 'clean',
145 'i' => 'install',
146 'm' => 'make',
147 't' => 'test',
148 );
149
150my @cpan_options = grep { $_ ne $Default } sort keys %CPAN_METHODS;
151
152my $arg_count = @ARGV;
153my %options;
154
155Getopt::Std::getopts(
156 join( '', @cpan_options, $META_OPTIONS ), \%options );
157
158if( $options{h} )
159 {
160 print STDERR "Printing help message -- ignoring other arguments\n"
161 if $arg_count > 1;
162
163 print STDERR "Use perldoc to read the documentation\n";
164 exit 0;
165 }
166elsif( $options{v} )
167 {
168 print STDERR "Printing version message -- ignoring other arguments\n"
169
170 if $arg_count > 1;
171
172 my $CPAN_VERSION = CPAN->VERSION;
173 print STDERR "cpan script version $VERSION\n" .
174 "CPAN.pm version $CPAN_VERSION\n";
175 exit 0;
176 }
177elsif( $options{a} )
178 {
179 print "Creating autobundle in ", $CPAN::Config->{cpan_home},
180 "/Bundle\n";
181 print STDERR "Creating autobundle -- ignoring other arguments\n"
182 if $arg_count > 1;
183
184 CPAN::Shell->autobundle;
185 exit 0;
186 }
187elsif( $options{r} )
188 {
189 print STDERR "Creating autobundle -- ignoring other arguments\n"
190 if $arg_count > 1;
191
192 CPAN::Shell->recompile;
193 }
194else
195 {
196 my $switch = '';
197
198 foreach my $option ( @cpan_options )
199 {
200 next unless $options{$option};
201 $switch = $option;
202 last;
203 }
204
205 if( not $switch and @ARGV ) { $switch = $Default; }
206 elsif( not $switch and not @ARGV ) { CPAN::shell(); exit 0; }
207 elsif( $switch and not @ARGV )
208 { die "Nothing to $CPAN_METHODS{$switch}!\n"; }
209
210 my $method = $CPAN_METHODS{$switch};
211 die "CPAN.pm cannot $method!\n" unless CPAN::Shell->can( $method );
212
213 foreach my $arg ( @ARGV )
214 {
215 CPAN::Shell->$method( $arg );
216 }
217 }
218
2191;
220
221__END__
222:endofperl
Note: See TracBrowser for help on using the repository browser.