X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FScript%2FCreate.pm;h=5013fc759eea57b8ebc377e7a1471364287a35f3;hb=73e4f0f19c278740fa95796e30efb90a7b779713;hp=b0b0b66beb3b66b5d3e6cac3ab1f610117f58d1d;hpb=4e45780e0eb1ea96cc9402e16429de10fe6b5209;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Script/Create.pm b/lib/Catalyst/Script/Create.pm index b0b0b66..5013fc7 100644 --- a/lib/Catalyst/Script/Create.pm +++ b/lib/Catalyst/Script/Create.pm @@ -6,31 +6,60 @@ use Catalyst::Helper; use MooseX::Types::Moose qw/Str Bool/; use namespace::autoclean; -has app => (isa => Str, is => 'ro', required => 1); - -sub new_with_options { shift->new(@_) } +with "MooseX::Getopt"; + +has _app => ( + reader => 'app', + init_arg => 'app', + traits => [qw(NoGetopt)], + isa => Str, + is => 'ro', +); + +has force => ( + traits => [qw(Getopt)], + cmd_aliases => 'nonew', + isa => Bool, + is => 'ro', + documentation => qq{ force new scripts } +); + +has help => ( + traits => [qw(Getopt)], + cmd_aliases => 'h', + isa => Bool, + is => 'ro', + documentation => qq{ display this help and exits }, +); + +has debug => ( + traits => [qw(Getopt)], + cmd_aliases => 'd', + isa => Bool, + is => 'ro', + documentation => qq{ force debug mode } +); + +has mechanize => ( + traits => [qw(Getopt)], + cmd_aliases => 'mech', + isa => Bool, + is => 'ro', + documentation => qq{ use WWW::Mechanize }, +); sub run { my ($self) = @_; -my $force = 0; -my $mech = 0; -my $help = 0; -GetOptions( - 'nonew|force' => \$force, - 'mech|mechanize' => \$mech, - 'help|?' => \$help - ); -pod2usage(1) if ( $help || !$ARGV[0] ); + pod2usage(1) if ( $self->help || !$ARGV[0] ); -my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } ); + my $helper = Catalyst::Helper->new( { '.newfiles' => !$self->force, mech => $self->mech } ); -pod2usage(1) unless $helper->mk_component( $self->app, @ARGV ); + pod2usage(1) unless $helper->mk_component( $self->app, @ARGV ); } -no Moose; __PACKAGE__->meta->make_immutable; 1;