Commit | Line | Data |
0ba6e8aa |
1 | package Catalyst::Script::Create; |
a24a5860 |
2 | use Moose; |
4ebd5ecf |
3 | use Catalyst::Helper; |
d3082fac |
4 | use MooseX::Types::Moose qw/Bool/; |
f4a497bb |
5 | use namespace::autoclean; |
4ebd5ecf |
6 | |
d3082fac |
7 | with 'Catalyst::ScriptRole'; |
73e4f0f1 |
8 | |
9 | has force => ( |
ab7eb5a9 |
10 | traits => [qw(Getopt)], |
73e4f0f1 |
11 | cmd_aliases => 'nonew', |
12 | isa => Bool, |
13 | is => 'ro', |
d3082fac |
14 | documentation => 'Force new scripts', |
73e4f0f1 |
15 | ); |
16 | |
17 | has debug => ( |
ab7eb5a9 |
18 | traits => [qw(Getopt)], |
73e4f0f1 |
19 | cmd_aliases => 'd', |
20 | isa => Bool, |
21 | is => 'ro', |
d3082fac |
22 | documentation => 'Force debug mode', |
73e4f0f1 |
23 | ); |
24 | |
25 | has mechanize => ( |
ab7eb5a9 |
26 | traits => [qw(Getopt)], |
73e4f0f1 |
27 | cmd_aliases => 'mech', |
28 | isa => Bool, |
29 | is => 'ro', |
d3082fac |
30 | documentation => 'use WWW::Mechanize', |
73e4f0f1 |
31 | ); |
2824ec8d |
32 | |
33 | sub run { |
f4a497bb |
34 | my ($self) = @_; |
4ebd5ecf |
35 | |
d3082fac |
36 | $self->_display_help if ( !$ARGV[0] ); |
4ebd5ecf |
37 | |
73e4f0f1 |
38 | my $helper = Catalyst::Helper->new( { '.newfiles' => !$self->force, mech => $self->mech } ); |
4ebd5ecf |
39 | |
d3082fac |
40 | $self->_display_help unless $helper->mk_component( $self->app, @ARGV ); |
2824ec8d |
41 | |
42 | } |
4ebd5ecf |
43 | |
d6e8e664 |
44 | __PACKAGE__->meta->make_immutable; |
0ba6e8aa |
45 | 1; |
4ebd5ecf |
46 | |
47 | =head1 NAME |
48 | |
d3082fac |
49 | Catalyst::Script::Create - Create a new Catalyst Component |
4ebd5ecf |
50 | |
51 | =head1 SYNOPSIS |
52 | |
d3082fac |
53 | myapp_create.pl [options] model|view|controller name [helper] [options] |
4ebd5ecf |
54 | |
55 | Options: |
56 | -force don't create a .new file where a file to be created exists |
57 | -mechanize use Test::WWW::Mechanize::Catalyst for tests if available |
58 | -help display this help and exits |
59 | |
60 | Examples: |
d3082fac |
61 | myapp_create.pl controller My::Controller |
62 | myapp_create.pl controller My::Controller BindLex |
63 | myapp_create.pl -mechanize controller My::Controller |
64 | myapp_create.pl view My::View |
65 | myapp_create.pl view MyView TT |
66 | myapp_create.pl view TT TT |
67 | myapp_create.pl model My::Model |
68 | myapp_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\ |
4ebd5ecf |
69 | dbi:SQLite:/tmp/my.db |
d3082fac |
70 | myapp_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\ |
4ebd5ecf |
71 | dbi:Pg:dbname=foo root 4321 |
72 | |
73 | See also: |
74 | perldoc Catalyst::Manual |
75 | perldoc Catalyst::Manual::Intro |
76 | |
77 | =head1 DESCRIPTION |
78 | |
79 | Create a new Catalyst Component. |
80 | |
81 | Existing component files are not overwritten. If any of the component files |
82 | to be created already exist the file will be written with a '.new' suffix. |
83 | This behavior can be suppressed with the C<-force> option. |
84 | |
85 | =head1 AUTHORS |
86 | |
87 | Catalyst Contributors, see Catalyst.pm |
88 | |
89 | =head1 COPYRIGHT |
90 | |
91 | This library is free software, you can redistribute it and/or modify |
92 | it under the same terms as Perl itself. |
93 | |
94 | =cut |