package Catalyst::Script::Create;
use Moose;
-use Catalyst::Helper;
use MooseX::Types::Moose qw/Bool/;
use namespace::autoclean;
with 'Catalyst::ScriptRole';
has force => (
+ traits => [qw(Getopt)],
cmd_aliases => 'nonew',
isa => Bool,
is => 'ro',
);
has debug => (
+ traits => [qw(Getopt)],
cmd_aliases => 'd',
isa => Bool,
is => 'ro',
);
has mechanize => (
+ traits => [qw(Getopt)],
cmd_aliases => 'mech',
isa => Bool,
is => 'ro',
documentation => 'use WWW::Mechanize',
);
+has helper_class => ( isa => 'Str', is => 'ro', default => 'Catalyst::Helper' );
+
sub run {
my ($self) = @_;
- $self->_display_help if ( !$ARGV[0] );
+ $self->_exit_with_usage if !$self->ARGV->[0];
- my $helper = Catalyst::Helper->new( { '.newfiles' => !$self->force, mech => $self->mech } );
+ my $helper_class = $self->helper_class;
+ Class::MOP::load_class($helper_class);
+ my $helper = $helper_class->new( { '.newfiles' => !$self->force, mech => $self->mechanize } );
- $self->_display_help unless $helper->mk_component( $self->app, @ARGV );
+ $self->_exit_with_usage unless $helper->mk_component( $self->application_name, @ARGV );
}
__PACKAGE__->meta->make_immutable;
-1;
=head1 NAME
=head1 SYNOPSIS
-myapp_create.pl [options] model|view|controller name [helper] [options]
+ myapp_create.pl [options] model|view|controller name [helper] [options]
Options:
-force don't create a .new file where a file to be created exists
it under the same terms as Perl itself.
=cut
+