use Moose;
use MooseX::Types::Common::Numeric qw/PositiveInt/;
use MooseX::Types::Moose qw/ArrayRef Str Bool Int RegexpRef/;
+use Catalyst::Utils;
use namespace::autoclean;
with 'Catalyst::ScriptRole';
cmd_aliases => 'p',
isa => PositiveInt,
is => 'ro',
- default => 3000,
+ default => sub {
+ my $self = shift;
+ $ENV{ Catalyst::Utils::class2env($self->application_name . '_PORT')}||3000
+ },
documentation => 'Specify a different listening port (to the default port 3000)',
);
# port -p -port --port -l --listen
testOption( [ qw/-p 3001/ ], ['3001', undef, opthash()] );
testOption( [ qw/--port 3001/ ], ['3001', undef, opthash()] );
+{
+ local $ENV{TESTAPPTOTESTSCRIPTS_PORT} = 5000;
+ testOption( [ qw// ], [5000, undef, opthash()] );
+}
# fork -f -fork --fork -f --fork
testOption( [ qw/--fork/ ], ['3000', undef, opthash(fork => 1)] );