Subject: | Warning and fails to parse all command line options |
See attached testcase.
Use of uninitialized value in list assignment at
/Volumes/Data/PerlModules/moosex-getopt/lib/MooseX/Getopt.pm line 107.
v5.10.1 built for darwin-thread-multi-2level
Cheers
Maroš
Subject: | 103_fail.t |
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 4;
{
package App;
use Moose;
use Moose::Util::TypeConstraints;
has 'TrackingNumber' => (
is => 'rw',
isa => 'TrackingNumber',
documentation => 'Shipment tracking number',
);
subtype 'TrackingNumber'
=> as 'Str'
=> where {
my $trackingnumber = $_;
return 0
unless ($trackingnumber =~ m/^1Z(?<tracking>[A-Z0-9]{8}\d{7})(?<checksum>\d)$/);
return 1;
}
=> message { "Tracking numbers must start withn '1Z' and contain 15 additional characters" };
}
{
package App::Commandline;
use Moose;
extends qw(App);
with qw(MooseX::Getopt);
MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
'TrackingNumber' => '=s',
);
has 'otherparam' => (
is => 'rw',
isa => 'Str',
);
}
{
local @ARGV = ('--TrackingNumber','1Z1234567812345670','--otherparam','foo');
my $app = App::Commandline->new_with_options;
isa_ok($app, 'App');
isa_ok($app, 'App::Commandline');
is($app->TrackingNumber, '1Z1234567812345670', '... TrackingNumber is as expected');
is($app->otherparam, 'foo', '... otherparam is as expected');
}