Subject: | Option conflicts with method names? |
I want a command-line option of --from, so I define like so:
has from => qw/is rw isa DateTime/;
But when I try to instantiate via ->new_with_options I get this error:
Prototype mismatch: sub Example::CLI::from ($) vs none at
/usr/lib64/perl5/site_perl/5.8.8/Class/MOP/Package.pm line 101.
I'm guessing because my option name conflicts with an existing Moose
method. How would one get the command-line parser to recognize --from
without a warning?
The whole module is very basic:
use Moose;
use Moose::Util::TypeConstraints;
use DateTimeX::Easy;
with qw/MooseX::Getopt/;
subtype 'DateTime' => as 'Object' => where { $_->isa('DateTime') };
coerce 'DateTime' => from 'Str' => via { datetime($_) };
has tally => qw/is rw isa Bool/;
has edit => qw/is rw isa Bool/;
has punch => qw/is rw isa Bool/;
has from => qw/is rw isa Str/;
has to => qw/is rw isa Str/;
Hmm, I guess I could not import "from" from Moose::Util::TypeConstraints
It might be better if the warning was clearer, though.