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