Class::MOP::load_class was deprecated in Moose-2.1100
[gitmo/MooseX-Runnable.git] / bin / mx-run
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use MooseX::Runnable::Util::ArgParser;
7 use MooseX::Runnable::Invocation::MxRun;
8
9 exit run();
10
11 sub run {
12     my $args = MooseX::Runnable::Util::ArgParser->new(
13         argv => \@ARGV,
14     );
15
16     help() if $args->is_help;
17
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;
26     local $0 = "mx-run ... $app";
27
28     return MooseX::Runnable::Invocation::MxRun->new(
29         class       => $app,
30         plugins     => $args->plugins,
31         parsed_args => $args,
32     )->run($args->app_args);
33 }
34
35 sub help {
36     print <<'END';
37
38 This is mx-run, a utility for running MooseX::Runnable classes.
39
40 usage: mx-run <mx-run options> -- Class::Name <options for Class::Name>
41
42 mx-run options:
43
44     --help -? -h     Print this message
45     -I<path>         Add <path> to @INC before loading modules
46     -M<module>       use <module> immediately
47     +PluginName      Load PluginName (see MooseX::Runnable::Invocation)
48
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.
55
56 To get help for Class::Name, run:
57
58     mx-run Class::Name --help
59
60 Syntax examples:
61
62     mx-run -Ilib Class::Name                          # Local Class::Name
63     mx-run -Ilib -MCarp::Always +Debug -- Class::Name # Debugging
64
65 END
66
67     exit 1;
68 }
69
70 __END__
71
72 =head1 NAME
73
74 mx-run - script to run MooseX::Runnable classes
75
76 =head1 SEE ALSO
77
78 L<MooseX::Runnable>