| 1 | 12 | ▶ | use v5.26; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 12 | ▶ | use Object::Pad qw(:experimental(mop)); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | class Getopt::Pad::Result { | ||||||||||
| 5 | # Carp is called fully qualified: an imported croak would be a method | ||||||||||
| 6 | # of every Result and reserve its name for no reason. | ||||||||||
| 7 | 12 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 12 | our $VERSION = '0.06'; | |||||||||
| 10 | |||||||||||
| 11 | # Names Perl looks up on an object by itself; a Reader by one of these | ||||||||||
| 12 | # would run at the wrong time with the wrong arguments. | ||||||||||
| 13 | 12 | my %isPerlHook = map { $_ => 1 } qw(DESTROY AUTOLOAD); | |||||||||
| 14 | |||||||||||
| 15 | field $command :param :reader = undef; | ||||||||||
| 16 | 6 | ▶ | field $subcommand :param :reader = undef; | ||||||||
|
Subroutine
command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 17 | 30 | ▶ | field $helper :param = undef; | ||||||||
|
Subroutine
subcommand: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | |||||||||||
| 19 | # Whether a Reader named $name would clash with what every Result | ||||||||||
| 20 | # already answers to: a method (including the ones Object::Pad and | ||||||||||
| 21 | # UNIVERSAL provide), a constructor param, or a Perl hook. Derived from | ||||||||||
| 22 | # the class itself, so nothing here can drift from it. | ||||||||||
| 23 | 611 | ▶ | method reservesReader :common ($name) { | ||||||||
|
Subroutine
reservesReader: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 24 | 611 | ▶ | return 1 if $isPerlHook{$name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 608 | ▶ | return 1 if $class->can($name); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 597 | my @params = map { $_->get_attribute_value('param') } grep { $_->has_attribute('param') } Object::Pad::MOP::Class->for_class($class)->fields; | |||||||||
| 27 | 597 | ▶ | return (grep { $_ eq $name } @params) ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 12 | } | |||||||||
| 29 | |||||||||||
| 30 | 1 | ▶ | method help() { | ||||||||
|
Subroutine
help: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||
| 31 | 1 | ▶ | Carp::croak('Getopt::Pad: no help renderer attached to this result') unless defined $helper; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | $helper->printHelp; | |||||||||
| 33 | 0 | exit 0; | |||||||||
| 34 | 12 | } | |||||||||
| 35 | |||||||||||
| 36 | 1 | ▶ | method version() { | ||||||||
|
Subroutine
version: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||
| 37 | 1 | ▶ | Carp::croak('Getopt::Pad: no help renderer attached to this result') unless defined $helper; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | $helper->printVersion; | |||||||||
| 39 | 0 | exit 0; | |||||||||
| 40 | 12 | } | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 12 | 1; | |||||||||
| 44 | |||||||||||
| 45 | __END__ | ||||||||||