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