Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
tokubass committed Aug 22, 2016
1 parent 433e976 commit 8628743
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions lib/Getopt/CodeGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ sub generate_code {
=head1 SYNOPSIS
$ perl -Ilib -MGetopt::CodeGenerator='--foo a --bar 2 -- --mix 1 a --dry-run'
$ perl -Ilib -MGetopt::CodeGenerator='--foo a --bar 2 --mix 1 a --dry-run'
use Getopt::Long qw(:config posix_default no_ignore_case gnu_compat);
my %opt;
my $res = GetOptions(
'foo=s' => \$opt->{foo},
'bar=i' => \$opt->{bar},
'mix=s{2}' => \$opt->{mix},
'dry-run' => \$opt->{dry_run},
'foo=s' => \$opt{foo},
'bar=i' => \$opt{bar},
'mix=s{2}' => \@{$opt{mix}},
'dry-run' => \$opt{dry_run},
);
=head1 LICENSE
Expand All @@ -106,6 +106,11 @@ use Getopt::Long qw(:config posix_default no_ignore_case gnu_compat);
my %opt;
my $res = GetOptions(
? for my $struct (@{$_[0]}) {
'<?= $struct->opt_name . $struct->value_type . $struct->value_range ?>' => \$opt->{<?= $struct->value_key ?>},
? if($struct->value_range) {
'<?= $struct->opt_name . $struct->value_type . $struct->value_range ?>' => \@{$opt{<?= $struct->value_key ?>}},
? }
? else{
'<?= $struct->opt_name . $struct->value_type . $struct->value_range ?>' => \$opt{<?= $struct->value_key ?>},
? }
? }
);
2 changes: 1 addition & 1 deletion t/02_multi.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use warnings;
use Getopt::CodeGenerator;

subtest 'multi' => sub {
my @argv = (qw/ --foo 1 b -- --bar --opt-name1 /);
my @argv = (qw/ --foo 1 b --bar --opt-name1 /);

my $gen = Getopt::CodeGenerator->new(@argv);
my $opt = shift @$gen;
Expand Down

0 comments on commit 8628743

Please sign in to comment.