看来,为了在 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
中的语法,但似乎并非如此。
最佳答案
其 .ini
语法略有不同。
[Acknowledgements]
contributor = test foo
contributor = foo bar
除此之外,您还必须告诉 Config::MVP
(它负责处理 Dist::Zilla
的配置加载)您的插件的 contributor
选项可能有多个值:
sub mvp_multivalue_args { qw(contributors) }
关于perl - 如何将数组从 weaver.ini 传递到 Pod::Weaver 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6968200/