foreach my $opt ( @{ $params{options} } ) {
push @options, $opt->{opt_string};
- my $identifier = $opt->{name};
+ my $identifier = lc($opt->{name});
$identifier =~ s/\W/_/g; # Getopt::Long does this to all option names
$name_to_init_arg{$identifier} = $opt->{init_arg};
},
];
- my $identifier = $opt->{name};
+ my $identifier = lc($opt->{name});
$identifier =~ s/\W/_/g; # Getopt::Long does this to all option names
$name_to_init_arg{$identifier} = $opt->{init_arg};
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+{
+ package App;
+ use Moose;
+ with qw(MooseX::Getopt);
+
+ has 'TrackingNumber' => (
+ is => 'rw',
+ isa => 'Str',
+ );
+
+ has 'otherparam' => (
+ is => 'rw',
+ isa => 'Str',
+ );
+}
+
+{
+ local @ARGV = ('--TrackingNumber','1Z1234567812345670','--otherparam','foo');
+
+ my $app = App->new_with_options;
+ isa_ok($app, 'App');
+ is($app->TrackingNumber, '1Z1234567812345670', '... TrackingNumber is as expected');
+ is($app->otherparam, 'foo', '... otherparam is as expected');
+}