| 1 | package Getopt::Complete::LazyOptions; | ||||||||||
| 2 | |||||||||||
| 3 | 13 | our $VERSION = $Getopt::Complete::VERSION; | |||||||||
| 4 | |||||||||||
| 5 | 13 | our $AUTOLOAD; | |||||||||
| 6 | |||||||||||
| 7 | sub new { | ||||||||||
| 8 | 0 | ▶ | my ($class, $callback) = @_; | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 9 | 0 | return bless { callback => $callback }, $class; | |||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | sub AUTOLOAD { | ||||||||||
| 13 | 0 | ▶ | my ($c,$m) = ($AUTOLOAD =~ /^(.*)::([^\:]+)$/); | ||||||||
|
Subroutine
AUTOLOAD: not called CC=5 SCAR=27.6
| |||||||||||
| 14 | 0 | ▶ | return if $m eq 'DESTROY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | my $self = shift; | |||||||||
| 17 | 0 | my $callback = $self->{callback}; | |||||||||
| 18 | 0 | my @spec; | |||||||||
| 19 | 0 | ▶ | if (ref($callback) eq 'SCALAR') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 13 | ▶ | no strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 13 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 0 | my $class = $$callback; | |||||||||
| 23 | 0 | my $path = $class; | |||||||||
| 24 | 0 | $path =~ s/::/\//g; | |||||||||
| 25 | 0 | $path .= '.pm.opts'; | |||||||||
| 26 | 0 | my @possible = map { $_ . '/' . $path } @INC; | |||||||||
| 27 | 0 | my @actual = grep { -e $_ } @possible; | |||||||||
| 28 | #print STDERR ">> possible @possible\n\nactual @actual\n\n"; | ||||||||||
| 29 | 0 | my $spec; | |||||||||
| 30 | 0 | ▶ | if (@actual) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | my $data = `cat $actual[0]`; | |||||||||
| 32 | 0 | $spec = eval $data; | |||||||||
| 33 | } | ||||||||||
| 34 | else { | ||||||||||
| 35 | # print STDERR ">> redo $class!\n"; | ||||||||||
| 36 | 0 | local $ENV{GETOPT_COMPLETE_CACHE} = 1; | |||||||||
| 37 | 0 | eval "use $class"; | |||||||||
| 38 | 0 | ▶ | die $@ if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 13 | ▶ | no strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | 13 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | 0 | $spec = ${ $class . '::OPTS_SPEC' }; | |||||||||
| 42 | #print STDERR ">> got @spec\n"; | ||||||||||
| 43 | } | ||||||||||
| 44 | 0 | @spec = @$spec; | |||||||||
| 45 | } | ||||||||||
| 46 | else { | ||||||||||
| 47 | 0 | @spec = $self->{callback}(); | |||||||||
| 48 | } | ||||||||||
| 49 | 0 | %$self = ( | |||||||||
| 50 | sub_commands => [], | ||||||||||
| 51 | option_specs => {}, | ||||||||||
| 52 | completion_handlers => {}, | ||||||||||
| 53 | parse_errors => undef, | ||||||||||
| 54 | %$self, | ||||||||||
| 55 | ); | ||||||||||
| 56 | 0 | bless $self, 'Getopt::Complete::Options'; | |||||||||
| 57 | 0 | $self->_init(@spec); | |||||||||
| 58 | 0 | $self->$m(@_); | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 13 | 1; | |||||||||
| 62 | |||||||||||
| 63 | =pod | ||||||||||
| 64 | |||||||||||
| 65 | =head1 NAME | ||||||||||
| 66 | |||||||||||
| 67 | Getopt::Complete::LazyOptions - internal object used as a placeholder for unprocessed options | ||||||||||
| 68 | |||||||||||
| 69 | =head1 VERSION | ||||||||||
| 70 | |||||||||||
| 71 | This document describes Getopt::Complete::LazyOptions 0.25. | ||||||||||
| 72 | |||||||||||
| 73 | =head1 SYNOPSIS | ||||||||||
| 74 | |||||||||||
| 75 | use Getopt::Complete ( | ||||||||||
| 76 | "foo=n" => [11,22,33], | ||||||||||
| 77 | "bar=s" => "f", | ||||||||||
| 78 | ">" => sub { | ||||||||||
| 79 | my $values = []; | ||||||||||
| 80 | # code to generate completions for this option here... | ||||||||||
| 81 | return $values; | ||||||||||
| 82 | } | ||||||||||
| 83 | ); | ||||||||||
| 84 | |||||||||||
| 85 | =head1 DESCRIPTION | ||||||||||
| 86 | |||||||||||
| 87 | This class is used internally by Getopt::Complete::Options. | ||||||||||
| 88 | |||||||||||
| 89 | =cut | ||||||||||
| 90 | |||||||||||