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