removed MooseX::Command::* stuff for now
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / Create.pm
1 package Catalyst::Script::Create;
2 use Moose;
3 use Pod::Usage;
4 use Catalyst::Helper;
5 use MooseX::Types::Moose qw/Str Bool/;
6 use namespace::autoclean;
7
8 with "MooseX::Getopt";
9 #extends qw(MooseX::App::Cmd);
10
11
12 has _app => (
13     reader   => 'app',
14     init_arg => 'app',
15     traits => [qw(NoGetopt)],
16     isa => Str,
17     is => 'ro',
18 );
19
20 has force => (
21     traits => [qw(Getopt)],
22     cmd_aliases => 'nonew',
23     isa => Bool,
24     is => 'ro',
25     documentation => qq{ force new scripts }
26 );
27
28 has 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
36 has debug => (
37     traits => [qw(Getopt)],
38     cmd_aliases => 'd',
39     isa => Bool,
40     is => 'ro',
41     documentation => qq{ force debug mode }
42 );
43
44 has mechanize => (
45     traits => [qw(Getopt)],
46     cmd_aliases => 'mech',
47     isa => Bool,
48     is => 'ro',
49     documentation => qq{ use WWW::Mechanize },
50 );
51
52 sub run {
53     my ($self) = @_;
54
55
56     pod2usage(1) if ( $self->help || !$ARGV[0] );
57
58     my $helper = Catalyst::Helper->new( { '.newfiles' => !$self->force, mech => $self->mech } );
59
60     pod2usage(1) unless $helper->mk_component( $self->app, @ARGV );
61
62 }
63
64 __PACKAGE__->meta->make_immutable;
65 1;
66
67 =head1 NAME
68
69 boyosplace_create.pl - Create a new Catalyst Component
70
71 =head1 SYNOPSIS
72
73 boyosplace_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
99 Create a new Catalyst Component.
100
101 Existing component files are not overwritten.  If any of the component files
102 to be created already exist the file will be written with a '.new' suffix.
103 This behavior can be suppressed with the C<-force> option.
104
105 =head1 AUTHORS
106
107 Catalyst Contributors, see Catalyst.pm
108
109 =head1 COPYRIGHT
110
111 This library is free software, you can redistribute it and/or modify
112 it under the same terms as Perl itself.
113
114 =cut