| 1 | 11 | ▶ | use v5.26; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 11 | ▶ | use Object::Pad; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | 11 | ▶ | use Getopt::Pad::Config; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 11 | ▶ | use Getopt::Pad::Config::Format; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | class Getopt::Pad::Spec::Config :strict(params) { | ||
| 8 | 11 | ▶ | use Getopt::Pad::Util qw(specError); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 11 | our $VERSION = '0.06'; | |
| 11 | |||
| 12 | 11 | field $raw :param; | |
| 13 | |||
| 14 | 11 | field $format; | |
| 15 | 75 | ▶ | field $formatName :reader; |
|
Subroutine
formatName: called CC=1 SCAR=0.0
Pod
documented
| |||
| 16 | 11 | field $paths; | |
| 17 | 77 | ▶ | field $defaultPath :reader; |
|
Subroutine
defaultPath: called CC=1 SCAR=0.0
Pod
documented
| |||
| 18 | field $autoload = 1; | ||
| 19 | 66 | ▶ | field $io :reader; |
|
Subroutine
io: called CC=1 SCAR=0.0
Pod
documented
| |||
| 20 | |||
| 21 | ADJUST { | ||
| 22 | specError("config: expects a hash reference") if ref $raw ne 'HASH'; | ||
| 23 | my %spec = $raw->%*; | ||
| 24 | |||
| 25 | $formatName = delete $spec{format}; | ||
| 26 | specError("config: missing 'format'") if !defined $formatName; | ||
| 27 | $format = Getopt::Pad::Config::Format::registry()->resolve($formatName)->new; | ||
| 28 | |||
| 29 | $paths = delete $spec{paths} // []; | ||
| 30 | specError("config: 'paths' must be an array reference") if ref $paths ne 'ARRAY'; | ||
| 31 | |||
| 32 | $defaultPath = delete $spec{defaultPath}; | ||
| 33 | $autoload = (delete $spec{autoload} ? 1 : 0) if exists $spec{autoload}; | ||
| 34 | |||
| 35 | specError("config: unknown key(s): %s", join(', ', sort keys %spec)) if %spec; | ||
| 36 | |||
| 37 | $io = Getopt::Pad::Config->new( | ||
| 38 | format => $format, | ||
| 39 | formatName => $formatName, | ||
| 40 | paths => $paths, | ||
| 41 | defaultPath => $defaultPath, | ||
| 42 | autoload => $autoload, | ||
| 43 | ); | ||
| 44 | } | ||
| 45 | 11 | } | |
| 46 | |||
| 47 | 11 | 1; | |
| 48 | |||
| 49 | __END__ | ||