Skip to content

Commit

Permalink
Use a parser object
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Dec 2, 2018
1 parent f4d26bb commit 0e83247
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/App/Ack/ConfigLoader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -613,17 +613,15 @@ sub _remove_default_options_if_needed {

my $should_remove = 0;

my $old_args = Getopt::Long::Configure( @STD, 'no_auto_abbrev', 'pass_through' );
my $p = Getopt::Long::Parser->new( config => [ @STD, 'no_auto_abbrev', 'pass_through' ] );

foreach my $index ( $default_index + 1 .. $#{$sources} ) {
my $args = $sources->[$index]->{contents};

if (ref($args)) {
local @ARGV = @{$args};
Getopt::Long::GetOptions(
$p->getoptionsfromarray( $args,
'ignore-ack-defaults' => \$should_remove,
);
@{$args} = @ARGV;
}
else {
( undef, $sources->[$index]{contents} ) = Getopt::Long::GetOptionsFromString($args,
Expand All @@ -632,8 +630,6 @@ sub _remove_default_options_if_needed {
}
}

Getopt::Long::Configure( $old_args );

return $sources unless $should_remove;

my @copy = @{$sources};
Expand Down

0 comments on commit 0e83247

Please sign in to comment.