2

因此,为了在weaver.ini插件本身中传递某些东西,似乎需要 Moose 属性。所以如果我有这样的东西weaver.ini

[Acknowledgements]
contributors = 'test foo' 'foo bar'

我的插件中需要一个相应的属性。

has contributors => (
    is      => 'rw',
    isa     => 'ArrayRef[Str]',
    traits  => [ 'Array' ],
    default => sub { [ ] },
    handles => {
        contributors_count => 'count',
    },
);

但是,我收到了错误

Attribute (contributors) does not pass the type constraint because: Validation failed for 'ArrayRef[Str]' with value 'test foo' 'foo bar' at /home/xenoterracide/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux-thread-multi/Moose/Meta/Attribute.pm line 1248

我不确定我哪里出错了。我试过改变语法,weaver.ini但似乎不是这样。

4

1 回答 1

3

.ini语法略有不同。

[Acknowledgements]
contributor = test foo
contributor = foo bar

除此之外,您还必须告诉您插件的选项可能有多个值Config::MVP,这是负责Dist::Zilla加载配置的原因:contributor

sub mvp_multivalue_args { qw(contributors) }
于 2011-08-06T18:05:19.003 回答