是否可以将 MooseX 元属性与 Moops 一起使用?
考虑这个 Moose 示例代码:
use v5.14;
use strict;
use warnings;
package TraitTest;
use Moose;
with 'MooseX::Getopt';
has opt1 => (
traits => ['Getopt'],
is => 'ro',
isa => 'Bool',
cmd_aliases => ['o']
);
1;
package main;
print TraitTest->new_with_options()->opt1 ? "yes\n" : "no\n";
我试图将其转换为 Moops,如下所示:
use v5.14;
use strict;
use warnings;
use Moops;
class TraitTest
with MooseX::Getopt
{
has opt1 => (
# metaclass => 'Getopt', # also not working
traits => ['Getopt'],
is => 'ro',
isa => 'Bool',
cmd_aliases => ['o']
);
}
print TraitTest->new_with_options()->opt1 ? "yes\n" : "no\n";