| Catalyst-Runtime documentation | Contained in the Catalyst-Runtime distribution. |
Catalyst::ScriptRole - Common functionality for Catalyst scripts.
package MyApp::Script::Foo;
use Moose;
use namespace::autoclean;
with 'Catalyst::ScriptRole';
sub _application_args { ... }
Role with the common functionality of Catalyst scripts.
The method invoked to run the application.
The name of the application class, e.g. MyApp
Catalyst Contributors, see Catalyst.pm
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst-Runtime documentation | Contained in the Catalyst-Runtime distribution. |
package Catalyst::ScriptRole; use Moose::Role; use MooseX::Types::Moose qw/Str Bool/; use Pod::Usage; use MooseX::Getopt; use namespace::autoclean; with 'MooseX::Getopt' => { -excludes => [qw/ _getopt_spec_warnings _getopt_spec_exception _getopt_full_usage /], }; has application_name => ( traits => ['NoGetopt'], isa => Str, is => 'ro', required => 1, ); sub _getopt_spec_exception {} sub _getopt_spec_warnings { shift; warn @_; } sub _getopt_full_usage { my $self = shift; pod2usage(); exit 0; } sub run { my $self = shift; $self->_run_application; } sub _application_args { () } sub _run_application { my $self = shift; my $app = $self->application_name; Class::MOP::load_class($app); $app->run($self->_application_args); } 1;