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