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