File Coverage

blib/lib/Catalyst/Script/Create.pm
Criterion Covered Total %
statement 16 17 94.1
branch 4 4 100.0
condition n/a
subroutine 4 5 80.0
pod 0 1 0.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package Catalyst::Script::Create;
2 2     2   1808 use Moose;
  2         5  
  2         13  
3 2     2   14446 use Class::Load 'load_class';
  2         12  
  2         137  
4 2     2   501 use namespace::clean -except => [ 'meta' ];
  2         5997  
  2         20  
5              
6             with 'Catalyst::ScriptRole';
7              
8             has force => (
9             traits => [qw(Getopt)],
10             cmd_aliases => 'nonew',
11             isa => 'Bool',
12             is => 'ro',
13             documentation => 'Force new scripts',
14             );
15              
16             has debug => (
17             traits => [qw(Getopt)],
18             cmd_aliases => 'd',
19             isa => 'Bool',
20             is => 'ro',
21             documentation => 'Force debug mode',
22             );
23              
24             has mechanize => (
25             traits => [qw(Getopt)],
26             cmd_aliases => 'mech',
27             isa => 'Bool',
28             is => 'ro',
29             documentation => 'use WWW::Mechanize',
30             );
31              
32             has helper_class => (
33             isa => 'Str',
34             is => 'ro',
35             builder => '_build_helper_class',
36             );
37              
38 0     0   0 sub _build_helper_class { 'Catalyst::Helper' }
39              
40             sub run {
41 3     3 0 9935 my ($self) = @_;
42              
43 3 100       82 $self->print_usage_text if !$self->ARGV->[0];
44              
45 3         118 my $helper_class = $self->helper_class;
46 3         17 load_class($helper_class);
47 3         192 my $helper = $helper_class->new( { '.newfiles' => !$self->force, mech => $self->mechanize } );
48              
49 3 100       1649 $self->print_usage_text unless $helper->mk_component( $self->application_name, @{$self->extra_argv} );
  3         110  
50              
51             }
52              
53             __PACKAGE__->meta->make_immutable;
54             1;
55              
56             =head1 NAME
57              
58             Catalyst::Script::Create - Create a new Catalyst Component
59              
60             =head1 SYNOPSIS
61              
62             myapp_create.pl [options] model|view|controller name [helper] [options]
63              
64             Options:
65             --force don't create a .new file where a file to be created exists
66             --mechanize use Test::WWW::Mechanize::Catalyst for tests if available
67             --help display this help and exits
68              
69             Examples:
70             myapp_create.pl controller My::Controller
71             myapp_create.pl controller My::Controller BindLex
72             myapp_create.pl --mechanize controller My::Controller
73             myapp_create.pl view My::View
74             myapp_create.pl view MyView TT
75             myapp_create.pl view TT TT
76             myapp_create.pl model My::Model
77             myapp_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
78             dbi:SQLite:/tmp/my.db
79             myapp_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
80             dbi:Pg:dbname=foo root 4321
81              
82             See also:
83             perldoc Catalyst::Manual
84             perldoc Catalyst::Manual::Intro
85              
86             =head1 DESCRIPTION
87              
88             Create a new Catalyst Component.
89              
90             Existing component files are not overwritten. If any of the component files
91             to be created already exist the file will be written with a '.new' suffix.
92             This behavior can be suppressed with the C<--force> option.
93              
94             =head1 SEE ALSO
95              
96             L<Catalyst::ScriptRunner>
97              
98             =head1 AUTHORS
99              
100             Catalyst Contributors, see Catalyst.pm
101              
102             =head1 COPYRIGHT
103              
104             This library is free software, you can redistribute it and/or modify
105             it under the same terms as Perl itself.
106              
107             =cut
108