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