added documentation
[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;
f4a497bb 6use MooseX::Types::Moose qw/Str/;
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
0ba6e8aa 331;
4ebd5ecf 34
35=head1 NAME
36
37boyosplace_create.pl - Create a new Catalyst Component
38
39=head1 SYNOPSIS
40
41boyosplace_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
67Create a new Catalyst Component.
68
69Existing component files are not overwritten. If any of the component files
70to be created already exist the file will be written with a '.new' suffix.
71This behavior can be suppressed with the C<-force> option.
72
73=head1 AUTHORS
74
75Catalyst Contributors, see Catalyst.pm
76
77=head1 COPYRIGHT
78
79This library is free software, you can redistribute it and/or modify
80it under the same terms as Perl itself.
81
82=cut