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