Class::MOP::load_class( $plugin );
+ my $does_cmdline = $plugin->meta->
+ does_role('MooseX::Runnable::Invocation::Plugin::Role::CmdlineArgs');
+
my $args;
- if($plugin->meta->does_role('MooseX::Runnable::Invocation::Plugin::Role::CmdlineArgs')){
+ if($does_cmdline){
$args = eval {
$plugin->_build_initargs_from_cmdline(
@{$self->plugins->{$orig}},
confess "Error building initargs for $plugin: $@";
}
}
+ elsif(!$does_cmdline && scalar @{$self->plugins->{$orig}} > 0){
+ confess "You supplied arguments to the $orig plugin, but it".
+ " does not know how to accept them. Perhaps the plugin".
+ " should consume the".
+ " 'MooseX::Runnable::Invocation::Plugin::Role::CmdlineArgs'".
+ " role?";
+ }
$plugin->meta->apply(
$self,
use strict;
use warnings;
use Test::Exception;
-use Test::More tests => 4;
+use Test::More tests => 6;
use MooseX::Runnable::Invocation;
}
}
+{ package Argless;
+ use Moose::Role;
+}
+
my $i;
lives_ok {
$i = MooseX::Runnable::Invocation->new(
ok $i->run, 'ran ok';
is $initargs, 'foo,bar,baz', 'got initargs';
+throws_ok {
+ MooseX::Runnable::Invocation->new(
+ class => 'Class',
+ plugins => {
+ '+Argless' => ['args go here'],
+ },
+ );
+} qr/Perhaps/, 'argless + args = error';
-
+lives_ok {
+ MooseX::Runnable::Invocation->new(
+ class => 'Class',
+ plugins => {
+ '+Argless' => [],
+ },
+ );
+} 'argless + no args = ok';