add prototype Profile plugin
[gitmo/MooseX-Runnable.git] / lib / MooseX / Runnable / Invocation / Plugin / Profile.pm
1 package MooseX::Runnable::Invocation::Plugin::Profile;
2 use Moose::Role;
3
4 before 'load_class' => sub {
5     my ($self) = @_;
6     confess 'The Profile plugin cannot be used when not invoked via mx-urn'
7       unless $self->does('MooseX::Runnable::Invocation::Role::WithParsedArgs');
8
9     my @cmdline = $self->parsed_args->guess_cmdline(
10         perl_flags      => ['-d:NYTProf'],
11         without_plugins => ['Profile', '+'.__PACKAGE__],
12     );
13
14     eval { $self->_debug_message(
15         "Re-execing with ". join ' ' , @cmdline,
16     )};
17
18     exec(@cmdline);
19 };
20
21 1;