convert to Distar
[catagits/Catalyst-Runtime.git] / script / catalyst.pl
CommitLineData
fc7ec1d9 1#!/usr/bin/perl -w
2
3use strict;
4use Getopt::Long;
5use Pod::Usage;
4be02e43 6BEGIN {
4ba28188 7eval " use Catalyst::Devel 1.0; ";
d1338286 8
9if ($@) {
10 die <<END;
11To use the Catalyst development tools including catalyst.pl and the
12generated script/myapp_create.pl you need Catalyst::Helper, which is
13part of the Catalyst-Devel distribution. Please install this via a
14vendor package or by running one of -
15
16 perl -MCPAN -e 'install Catalyst::Devel'
17 perl -MCPANPLUS -e 'install Catalyst::Devel'
18END
19
20}
4be02e43 21};
fc7ec1d9 22
4f9ca6ed 23use Catalyst::Helper;
24
4e90e3c1 25my $force = 0;
26my $help = 0;
27my $makefile = 0;
28my $scripts = 0;
fc7ec1d9 29
1c773d18 30GetOptions(
640faa87 31 'help|?' => \$help,
32 'force|nonew' => \$force,
4e90e3c1 33 'makefile' => \$makefile,
640faa87 34 'scripts' => \$scripts,
1c773d18 35);
fc7ec1d9 36
37pod2usage(1) if ( $help || !$ARGV[0] );
38
34d28dfd 39my $helper = Catalyst::Helper->new(
40 {
41 '.newfiles' => !$force,
42 'makefile' => $makefile,
43 'scripts' => $scripts,
dd234b22 44 name => $ARGV[0],
34d28dfd 45 }
46);
dd234b22 47# Pass $ARGV[0] for compatibility with old ::Devel
fc7ec1d9 48pod2usage(1) unless $helper->mk_app( $ARGV[0] );
49
501;
51__END__
52
53=head1 NAME
54
55catalyst - Bootstrap a Catalyst application
56
57=head1 SYNOPSIS
58
d459eb44 59catalyst.pl [options] application-name
fc7ec1d9 60
b4b01a8a 61'catalyst.pl' creates a skeleton for a new application, and allows you to
62upgrade the skeleton of your old application.
63
fc7ec1d9 64 Options:
640faa87 65 -force don't create a .new file where a file to be created exists
b4b01a8a 66 -help display this help and exit
67 -makefile only update Makefile.PL
68 -scripts only update helper scripts
b4b01a8a 69
70 application-name must be a valid Perl module name and can include "::",
71 which will be converted to '-' in the project name.
fc7ec1d9 72
fc7ec1d9 73
74 Examples:
d459eb44 75 catalyst.pl My::App
76 catalyst.pl MyApp
fc7ec1d9 77
ae1e6b59 78 To upgrade your app to a new version of Catalyst:
640faa87 79 catalyst.pl -force -scripts MyApp
ae1e6b59 80
03a53815 81
fc7ec1d9 82=head1 DESCRIPTION
83
4be535b1 84The C<catalyst.pl> script bootstraps a Catalyst application, creating a
85directory structure populated with skeleton files.
86
87The application name must be a valid Perl module name. The name of the
88directory created is formed from the application name supplied, with double
89colons replaced with hyphens (so, for example, the directory for C<My::App> is
90C<My-App>).
91
92Using the example application name C<My::App>, the application directory will
93contain the following items:
94
95=over 4
96
97=item README
98
99a skeleton README file, which you are encouraged to expand on
100
4be535b1 101=item Changes
102
103a changes file with an initial entry for the creation of the application
104
105=item Makefile.PL
106
b1882228 107Makefile.PL uses the C<Module::Install> system for packaging and distribution
108of the application.
4be535b1 109
110=item lib
111
112contains the application module (C<My/App.pm>) and
113subdirectories for model, view, and controller components (C<My/App/M>,
114C<My/App/V>, and C<My/App/C>).
115
116=item root
117
118root directory for your web document content. This is left empty.
119
120=item script
121
122a directory containing helper scripts:
123
124=over 4
125
b1882228 126=item C<myapp_create.pl>
4be535b1 127
128helper script to generate new component modules
129
b1882228 130=item C<myapp_server.pl>
4be535b1 131
132runs the generated application within a Catalyst test server, which can be
133used for testing without resorting to a full-blown web server configuration.
134
b1882228 135=item C<myapp_cgi.pl>
4be535b1 136
137runs the generated application as a CGI script
138
b1882228 139=item C<myapp_fastcgi.pl>
4be535b1 140
141runs the generated application as a FastCGI script
142
b1882228 143=item C<myapp_test.pl>
4be535b1 144
6356febf 145runs an action of the generated application from the command line.
4be535b1 146
147=back
148
149=item t
150
151test directory
152
153=back
154
4be535b1 155The application module generated by the C<catalyst.pl> script is functional,
1c773d18 156although it reacts to all requests by outputting a friendly welcome screen.
4be535b1 157
4be535b1 158=head1 NOTE
159
160Neither C<catalyst.pl> nor the generated helper script will overwrite existing
161files. In fact the scripts will generate new versions of any existing files,
162adding the extension C<.new> to the filename. The C<.new> file is not created
163if would be identical to the existing file.
164
165This means you can re-run the scripts for example to see if newer versions of
166Catalyst or its plugins generate different code, or to see how you may have
167changed the generated code (although you do of course have all your code in a
168version control system anyway, don't you ...).
169
03a53815 170=head1 SEE ALSO
171
4be535b1 172L<Catalyst::Manual>, L<Catalyst::Manual::Intro>
03a53815 173
2f381252 174=head1 AUTHORS
4be535b1 175
2f381252 176Catalyst Contributors, see Catalyst.pm
fc7ec1d9 177
178=head1 COPYRIGHT
179
1c773d18 180This library is free software, you can redistribute it and/or modify it under
181the same terms as Perl itself.
fc7ec1d9 182
183=cut