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