GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MooseX::Runnable(3) User Contributed Perl Documentation MooseX::Runnable(3)

MooseX::Runnable - Tag a class as a runnable application

version 0.10

Create a class, tag it runnable, and provide a "run" method:

    package App::HelloWorld;
    use feature 'say';
    use Moose;

    with 'MooseX::Runnable';

    sub run {
       my ($self,$name) = @_;
       say "Hello, $name.";
       return 0; # success
    }

Then you can run this class as an application with the included "mx-run" script:

    $ mx-run App::HelloWorld jrockway
    Hello, jrockway.
    $

"MooseX::Runnable" supports MooseX::Getopt, and other similar systems (and is extensible, in case you have written such a system).

MooseX::Runnable is a framework for making classes runnable applications. This role doesn't do anything other than tell the rest of the framework that your class is a runnable application that has a "run" method which accepts arguments and returns the process' exit code.

This is a convention that the community has been using for a while. This role tells the computer that your class uses this convention, and let's the computer abstract away some of the tedium this entails.

Your class must implement "run". It accepts the command-line args (that were not consumed by another parser, if applicable) and returns an integer representing the UNIX exit value. "return 0" means success.

This is a script that accepts a "MooseX::Runnable" class and tries to run it, using "MooseX::Runnable::Run".

The syntax is:

  mx-run Class::Name

  mx-run <args for mx-run> -- Class::Name <args for Class::Name>

for example:

  mx-run -Ilib App::HelloWorld --args --go --here

or:

  mx-run -Ilib +Persistent --port 8080 -- App::HelloWorld --args --go --here

If you don't want to invoke your app with "mx-run", you can write a custom version using MooseX::Runnable::Run.

"MX::Runnable" is designed to be extensible; users can run plugins from the command-line, and application developers can add roles to their class to control behavior.

For example, if you consume MooseX::Getopt, the command-line will be parsed with "MooseX::Getopt". Any recognized args will be used to instantiate your class, and any extra args will be passed to "run".

Many of the plugins shipped are unstable; they may go away, change, break, etc. If there is no documentation for a plugin, it is probably just a prototype.

Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Runnable> (or bug-MooseX-Runnable@rt.cpan.org <mailto:bug-MooseX-Runnable@rt.cpan.org>).

There is also a mailing list available for users of this distribution, at <http://lists.perl.org/list/moose.html>.

There is also an irc channel available for users of this distribution, at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.

Jonathan Rockway <jrockway@cpan.org>

  • Jonathan Rockway <jon@jrock.us>
  • Karen Etheridge <ether@cpan.org>
  • Doug Bell <doug.bell@baml.com>
  • Duke Leto <jonathan@leto.net>

This software is copyright (c) 2009 by Jonathan Rockway.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2016-03-13 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.