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