Too slow
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / Create.pm
1 package Catalyst::Script::Create;
2 use Moose;
3 use strict;
4 use warnings;
5 use Getopt::Long;
6 use Pod::Usage;
7 use Catalyst::Helper;
8
9 sub new_with_options { shift->new }
10
11 sub run {
12     my ($appname) = @_;
13 my $force = 0;
14 my $mech  = 0;
15 my $help  = 0;
16
17 GetOptions(
18     'nonew|force'    => \$force,
19     'mech|mechanize' => \$mech,
20     'help|?'         => \$help
21  );
22
23 pod2usage(1) if ( $help || !$ARGV[0] );
24
25 my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
26
27 pod2usage(1) unless $helper->mk_component( $appname, @ARGV );
28
29 }
30
31 1;
32
33 =head1 NAME
34
35 boyosplace_create.pl - Create a new Catalyst Component
36
37 =head1 SYNOPSIS
38
39 boyosplace_create.pl [options] model|view|controller name [helper] [options]
40
41  Options:
42    -force        don't create a .new file where a file to be created exists
43    -mechanize    use Test::WWW::Mechanize::Catalyst for tests if available
44    -help         display this help and exits
45
46  Examples:
47    boyosplace_create.pl controller My::Controller
48    boyosplace_create.pl controller My::Controller BindLex
49    boyosplace_create.pl -mechanize controller My::Controller
50    boyosplace_create.pl view My::View
51    boyosplace_create.pl view MyView TT
52    boyosplace_create.pl view TT TT
53    boyosplace_create.pl model My::Model
54    boyosplace_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
55    dbi:SQLite:/tmp/my.db
56    boyosplace_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
57    dbi:Pg:dbname=foo root 4321
58
59  See also:
60    perldoc Catalyst::Manual
61    perldoc Catalyst::Manual::Intro
62
63 =head1 DESCRIPTION
64
65 Create a new Catalyst Component.
66
67 Existing component files are not overwritten.  If any of the component files
68 to be created already exist the file will be written with a '.new' suffix.
69 This behavior can be suppressed with the C<-force> option.
70
71 =head1 AUTHORS
72
73 Catalyst Contributors, see Catalyst.pm
74
75 =head1 COPYRIGHT
76
77 This library is free software, you can redistribute it and/or modify
78 it under the same terms as Perl itself.
79
80 =cut