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