X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FHelper.pm;h=ccdf5b72ff8d71f5f12727b806f85a5700b233ab;hb=a727119f14470f2443fa1e1c97e64bf697f1f715;hp=c747bb646aa3b01306fed5f9716ebbc17dae204a;hpb=ae7c52524547f43903b7dd9a4d741079726ac114;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index c747bb6..ccdf5b7 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -9,6 +9,7 @@ use IO::File; use FindBin; use Template; use Catalyst; +use Catalyst::Utils; use Catalyst::Exception; my %cache; @@ -61,8 +62,7 @@ sub mk_app { $self->{name} = $name; $self->{dir} = $name; $self->{dir} =~ s/\:\:/-/g; - $self->{appprefix} = lc $self->{dir}; - $self->{appprefix} =~ s/-/_/g; + $self->{appprefix} = Catalyst::Utils::appprefix($name); $self->{startperl} = $Config{startperl}; $self->{scriptgen} = $Catalyst::CATALYST_SCRIPT_GEN || 4; $self->{author} = $self->{author} = $ENV{'AUTHOR'} @@ -217,6 +217,7 @@ sub mk_file { $file .= '.new'; } if ( my $f = IO::File->new("> $file") ) { + binmode $f; print $f $content; print qq/created "$file"\n/; return 1; @@ -448,8 +449,8 @@ Sebastian Riedel, C =head1 LICENSE -This library is free software . You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut @@ -460,6 +461,7 @@ __appclass__ package [% name %]; use strict; +use warnings; # -Debug activates the debug mode for very useful log messages # Static::Simple will serve static files from the root directory @@ -468,10 +470,10 @@ use Catalyst qw/-Debug Static::Simple/; our $VERSION = '0.01'; # Configure the application -[% name %]->config( name => '[% name %]' ); +__PACKAGE__->config( name => '[% name %]' ); # Start the application -[% name %]->setup; +__PACKAGE__->setup; =head1 NAME @@ -521,8 +523,8 @@ sub default : Private { =head1 LICENSE -This library is free software . You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut @@ -632,8 +634,8 @@ Sebastian Riedel, C Copyright 2004 Sebastian Riedel. All rights reserved. -This library is free software. You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut __fastcgi__ @@ -642,11 +644,24 @@ __fastcgi__ BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' } use strict; +use Getopt::Long; +use Pod::Usage; use FindBin; use lib "$FindBin::Bin/../lib"; use [% name %]; -[% name %]->run; +my $help = 0; +my ( $listen, $nproc ); + +GetOptions( + 'help|?' => \$help, + 'listen|l=s' => \$listen, + 'nproc|n=i' => \$nproc, +); + +pod2usage(1) if $help; + +[% name %]->run( $listen, { nproc => $nproc } ); 1; @@ -656,7 +671,16 @@ use [% name %]; =head1 SYNOPSIS -See L +[% appprefix %]_server.pl [options] + + Options: + -? -help display this help and exits + -l -listen Socket path to listen on + (defaults to standard input) + can be HOST:PORT, :PORT or a + filesystem path + -n -nproc specify number of processes to keep + to serve requests (defaults to 1) =head1 DESCRIPTION @@ -670,8 +694,8 @@ Sebastian Riedel, C Copyright 2004 Sebastian Riedel. All rights reserved. -This library is free software. You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut __server__ @@ -758,8 +782,8 @@ Sebastian Riedel, C Copyright 2004 Sebastian Riedel. All rights reserved. -This library is free software. You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut __test__ @@ -815,8 +839,8 @@ Sebastian Riedel, C Copyright 2004 Sebastian Riedel. All rights reserved. -This library is free software. You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut __create__ @@ -881,14 +905,15 @@ Sebastian Riedel, C Copyright 2004 Sebastian Riedel. All rights reserved. -This library is free software. You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut __compclass__ package [% class %]; use strict; +use warnings; use base 'Catalyst::Base'; =head1 NAME @@ -907,16 +932,17 @@ Catalyst component. =over 4 -=item default - -=cut - -sub default : Private { - my ( $self, $c ) = @_; - - # Hello World - $c->response->output('Congratulations, [% class %] is on Catalyst!'); -} +# Uncomment, modify and add new actions to fit your needs +#=item default +# +#=cut +# +#sub default : Private { +# my ( $self, $c ) = @_; +# +# # Hello World +# $c->response->body('[% class %] is on Catalyst!'); +#} =back @@ -927,8 +953,8 @@ sub default : Private { =head1 LICENSE -This library is free software . You can redistribute it and/or modify -it under the same terms as perl itself. +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. =cut