Make ScriptRunner include the lib path.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ScriptRunner.pm
index 0f9aa8f..c0bb27a 100644 (file)
@@ -1,18 +1,48 @@
 package Catalyst::ScriptRunner;
 use Moose;
-#extends qw(MooseX::App::Cmd::Command);
-
+use FindBin;
+use lib;
+use File::Spec;
+use namespace::autoclean;
 
 sub run {
     my ($self, $class, $scriptclass) = @_;
     my $classtoload = "${class}::Script::$scriptclass";
 
+    lib->import(File::Spec->catdir($FindBin::Bin, '..', 'lib'));
+
     # FIXME - Error handling / reporting
     if ( eval { Class::MOP::load_class($classtoload) } ) {
-    } else {
+    }
+    else {
         $classtoload = "Catalyst::Script::$scriptclass";
         Class::MOP::load_class($classtoload);
     }
-    $classtoload->new_with_options( app => $class )->run;
+    $classtoload->new_with_options( application_name => $class )->run;
 }
-1;
+
+__PACKAGE__->meta->make_immutable;
+
+=head1 NAME
+
+Catalyst::ScriptRunner - The Catalyst Framework Script runner
+
+=head1 SYNOPSIS
+
+See L<Catalyst>.
+
+=head1 DESCRIPTION
+
+This class is responsible for running scripts, either in the application specific namespace
+(e.g. C<MyApp::Script::Server>), or the Catalyst namespace (e.g. C<Catalyst::Script::Server>)
+
+=head1 AUTHORS
+
+Catalyst Contributors, see Catalyst.pm
+
+=head1 COPYRIGHT
+
+This library is free software. You can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut