1 package MooseX::Runnable;
14 MooseX::Runnable - tag a class as a runnable application
18 Create a class, tag it runnable, and provide a C<run> method:
20 package App::HelloWorld;
24 with 'MooseX::Runnable';
27 my ($self,$name) = @_;
32 Then you can run this class as an application with the included
35 $ mx-run App::HelloWorld jrockway
39 C<MooseX::Runnable> supports L<MooseX::Getopt|MooseX::Getopt>, and
40 other similar systems (and is extensible, in case you have written
45 MooseX::Runnable is a framework for making classes runnable
46 applications. This role doesn't do anything other than tell the rest
47 of the framework that your class is a runnable application that has a
48 C<run> method which accepts arguments and returns the process' exit
51 This is a convention that the community has been using for a while.
52 This role tells the computer that your class uses this convention, and
53 let's the computer abstract away some of the tedium this entails.
55 =head1 REQUIRED METHODS
59 Your class must implement C<run>. It accepts the commandline args
60 (that were not consumed by another parser, if applicable) and returns
61 an integer representing the UNIX exit value. C<return 0> means
68 This is a script that accepts a C<MooseX::Runnable> class and tries to
69 run it, using C<MooseX::Runnable::Run>.
75 mx-run <args for mx-run> -- Class::Name <args for Class::Name>
79 mx-run -Ilib App::HelloWorld --args --go --here
83 mx-run -Ilib +Persistent --port 8080 -- App::HelloWorld --args --go --here
85 =head2 C<MooseX::Runnable::Run>
87 If you don't want to invoke your app with C<mx-run>, you can write a
88 custom version using L<MooseX::Runnable::Run|MooseX::Runnable::Run>.
92 C<MX::Runnable> is designed to be extensible; users can run plugins
93 from the command-line, and application developers can add roles to
94 their class to control behavior.
96 For example, if you consume L<MooseX::Getopt|MooseX::Getopt>, the
97 command-line will be parsed with C<MooseX::Getopt>. Any recognized
98 args will be used to instantiate your class, and any extra args will
103 Many of the plugins shipped are unstable; they may go away, change,
104 break, etc. If there is no documentation for a plugin, it is probably
109 L<http://github.com/jrockway/moosex-runnable>
113 Jonathan Rockway C<< <jrockway@cpan.org> >>
117 Copyright (c) 2009 Jonathan Rockway
119 This module is Free Software, you can redistribute it under the same
120 terms as Perl itself.