Fix passing correct key, re-add getopt trait as this is needed, my bad
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ScriptRunner.pm
CommitLineData
291722a8 1package Catalyst::ScriptRunner;
2use Moose;
d3082fac 3use namespace::autoclean;
291722a8 4
cc999ce2 5sub run {
6 my ($self, $class, $scriptclass) = @_;
c1c59374 7 my $classtoload = "${class}::Script::$scriptclass";
8
9 # FIXME - Error handling / reporting
10 if ( eval { Class::MOP::load_class($classtoload) } ) {
d3082fac 11 }
12 else {
d24d92d9 13 $classtoload = "Catalyst::Script::$scriptclass";
c1c59374 14 Class::MOP::load_class($classtoload);
d24d92d9 15 }
ab7eb5a9 16 $classtoload->new_with_options( application_name => $class )->run;
cc999ce2 17}
d3082fac 18
19__PACKAGE__->meta->make_immutable;
20
21=head1 NAME
22
23Catalyst::ScriptRunner - The Catalyst Framework Script runner
24
25=head1 SYNOPSIS
26
27See L<Catalyst>.
28
29=head1 DESCRIPTION
30
31This class is responsible for running scripts, either in the application specific namespace
32(e.g. C<MyApp::Script::Server>), or the Catalyst namespace (e.g. C<Catalyst::Script::Server>)
33
34=head1 AUTHORS
35
36Catalyst Contributors, see Catalyst.pm
37
38=head1 COPYRIGHT
39
40This library is free software. You can redistribute it and/or modify it under
41the same terms as Perl itself.
42
43=cut