Commit | Line | Data |
---|---|---|
d42333d2 | 1 | package MooseX::Runnable; |
2 | use Moose::Role; | |
3 | ||
4 | our $RUNNING_APP; | |
5 | ||
6 | requires 'run'; | |
7 | ||
8 | sub run_as_application { | |
9 | my $class = shift; | |
10 | my @args = @_; | |
11 | ||
12 | if($class->does('MooseX::Getopt')){ | |
13 | my $self = $class->new_with_options(@args); | |
14 | local $RUNNING_APP = $self; | |
15 | exit $self->run( $self->extra_argv ); | |
16 | } | |
17 | ||
18 | local $RUNNING_APP = $class->new(@args); | |
19 | exit $RUNNING_APP->run; | |
20 | } | |
21 | ||
22 | 1; |