| 1 | package App::Sandy::Role::ParseArgv; | ||
| 2 | # ABSTRACT: Getopt::Long wrapper. | ||
| 3 | |||
| 4 | 1 | ▶ | use App::Sandy::Base 'role'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | use Getopt::Long 'GetOptionsFromArray'; | ||
| 6 | |||
| 7 | our $VERSION = '0.25'; # VERSION | ||
| 8 | |||
| 9 | sub with_parser { | ||
| 10 | my ($self, $argv, @opt_spec) = @_; | ||
| 11 | my @argv = @{ $argv }; | ||
| 12 | my %opts; | ||
| 13 | |||
| 14 | Getopt::Long::Configure('gnu_getopt'); | ||
| 15 | |||
| 16 | GetOptionsFromArray( | ||
| 17 | \@argv, | ||
| 18 | \%opts, | ||
| 19 | @opt_spec | ||
| 20 | ) or die "Error parsing command-line arguments\n"; | ||
| 21 | |||
| 22 | return (\%opts, \@argv); | ||
| 23 | } | ||
| 24 | |||
| 25 | __END__ | ||