unless $getopt->isa('MooseX::Getopt::Session');
my $options = $getopt->options;
+ my $new_options = { %$options };
+
my @opts;
foreach my $attr (@attrs) {
my $opt_string = join '|', $flag, @aliases;
$opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type) if $type;
- $options->{$name} = undef;
- push @opts, $opt_string => \$options->{$name};
+ $new_options->{$name} = undef;
+ push @opts, $opt_string => \$new_options->{$name};
};
my $warnings = '';
$getopt->extra_argv( $extra_argv );
};
- # Filter not defined values in options hashref
- $options = { map { $_ => $options->{$_} } grep { defined $options->{$_} } keys %$options };
+ # Filter not defined values in new_options hashref
+ $new_options = { map { $_ => $new_options->{$_} } grep { defined $new_options->{$_} } keys %$new_options };
- $getopt->options( $options );
+ $getopt->options( $new_options );
die $warnings if $warnings;
- return $options;
+ return $new_options;
};