add changelog, $VERSION
[gitmo/MooseX-Runnable.git] / lib / MooseX / Runnable.pm
CommitLineData
d42333d2 1package MooseX::Runnable;
2use Moose::Role;
3
6a6431d0 4our $VERSION = '0.00_01';
5
d42333d2 6requires 'run';
7
c527660e 81;
9
10__END__
11
12=head1 NAME
13
14MooseX::Runnable - tag a class as a runnable application
15
16=head1 SYNOPSIS
d42333d2 17
c527660e 18Create a class, tag it runnable, and provide a C<run> method:
19
20 package App::HelloWorld;
21 use Moose;
22
23 with 'MooseX::Runnable';
24
25 sub run {
26 my $name = shift;
27 say "Hello, $name.";
00d7989a 28 return 0; # success
d42333d2 29 }
30
c527660e 31Then you can run this class as an application with the included
32C<mx-run> script:
d42333d2 33
c527660e 34 $ mx-run App::HelloWorld jrockway
35 Hello, jrockway.
36 $
37
38C<MooseX::Runnable> supports L<MooseX::Getopt|MooseX::Getopt>, and
39other similar systems (and is extensible, in case you have written
40such a system).
41
42=head1 DESCRIPTION
43
44MooseX::Runnable is a framework for making classes runnable
45applications. This role doesn't do anything other than tell the rest
46of the framework that your class is a runnable application that has a
47C<run> method which accepts arguments and returns the process' exit
48code.
49
50This is a convention that the community has been using for a while.
51This role tells the computer that your class uses this convention, and
52let's the computer abstract away some of the tedium this entails.
53
54=head1 REQUIRED METHODS
55
56=head1 THINGS YOU GET
57
58=head2 C<mx-run>
59
60This is a script that accepts a C<MooseX::Runnable> class and tries to
61run it, using C<MooseX::Runnable::Run>.
62
63The syntax is:
64
2503822b 65 mx-run <args for mx-run> -- Class::Name <args for Class::Name>
c527660e 66
67for example:
68
2503822b 69 mx-run -Ilib -- App::HelloWorld --args --go --here
c527660e 70
2503822b 71or:
72
73 mx-run -Ilib +Persistent --port 8080 -Persistent -- App::HelloWorld --args --go --here
c527660e 74=head2 C<MooseX::Runnable::Run>
75
76If you don't want to invoke your app with C<mx-run>, you can write a
77custom version using L<MooseX::Runnable::Run|MooseX::Runnable::Run>.