Commit | Line | Data |
c527660e |
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
2503822b |
6 | use MooseX::Runnable::Util::ArgParser; |
040d22bb |
7 | use MooseX::Runnable::Invocation::MxRun; |
441297a7 |
8 | |
9 | exit run(); |
10 | |
11 | sub run { |
2503822b |
12 | my $args = MooseX::Runnable::Util::ArgParser->new( |
13 | argv => \@ARGV, |
14 | ); |
441297a7 |
15 | |
2503822b |
16 | help() if $args->is_help; |
441297a7 |
17 | |
2503822b |
18 | # set @INC from -I... |
19 | unshift @INC, $_->stringify for $args->include_paths; |
20 | |
21 | # load -M... modules |
22 | do { eval "require $_"; die $@ if $@ } |
23 | for $args->modules; |
24 | |
25 | my $app = $args->class_name; |
c4e3f06e |
26 | local $0 = "mx-run ... $app"; |
27 | |
040d22bb |
28 | return MooseX::Runnable::Invocation::MxRun->new( |
29 | class => $app, |
30 | plugins => $args->plugins, |
31 | parsed_args => $args, |
2503822b |
32 | )->run($args->app_args); |
441297a7 |
33 | } |
34 | |
35 | sub help { |
36 | print <<'END'; |
37 | |
38 | This is mx-run, a utility for running MooseX::Runnable classes. |
2503822b |
39 | |
40 | usage: mx-run <mx-run options> -- Class::Name <options for Class::Name> |
41 | |
441297a7 |
42 | mx-run options: |
43 | |
44 | --help -? -h Print this message |
2503822b |
45 | -I<path> Add <path> to @INC before loading modules |
6a06028a |
46 | -M<module> use <module> immediately |
47 | +PluginName Load PluginName (see MooseX::Runnable::Invocation) |
48 | |
2503822b |
49 | Note that as soon as +PluginName is seen, all following -[IM] options |
50 | are ignored by mx-run, and are instead processed by PluginName. So |
51 | put them at the very beginning. |
52 | |
53 | In the simplest cases, where you use only -I or -M (no plugins), you |
54 | may omit the -- before the class name. |
441297a7 |
55 | |
56 | To get help for Class::Name, run: |
57 | |
58 | mx-run Class::Name --help |
2503822b |
59 | |
60 | Syntax examples: |
61 | |
62 | mx-run -Ilib Class::Name # Local Class::Name |
5d5f8fa1 |
63 | mx-run -Ilib -MCarp::Always +Debug -- Class::Name # Debugging |
2503822b |
64 | |
441297a7 |
65 | END |
66 | |
67 | exit 1; |
68 | } |
c527660e |
69 | |
70 | __END__ |
71 | |
72 | =head1 NAME |
73 | |
74 | mx-run - script to run MooseX::Runnable classes |
fc5720d5 |
75 | |
76 | =head1 SEE ALSO |
77 | |
78 | L<MooseX::Runnable> |