Getopt-Long-Descriptive

 view release on metacpan or  search on metacpan

lib/Getopt/Long/Descriptive/Opts.pm  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use strict;
# ABSTRACT: object representing command line switches
 
use Scalar::Util qw(blessed weaken);
 
#pod =head1 DESCRIPTION
#pod
#pod This class is the base class of all C<$opt> objects returned by
#pod L<Getopt::Long::Descriptive>.  In general, you do not want to think about this
#pod class, look at it, or alter it.  Seriously, it's pretty dumb.
#pod
#pod Every call to C<describe_options> will return a object of a new subclass of
#pod this class.  It will have a method for the canonical name of each option
#pod possible given the option specifications.

lib/Getopt/Long/Descriptive/Opts.pm  view on Meta::CPAN

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  return $meta->{specified_opts} if $meta->{specified_opts};
 
  my @keys = grep { $meta->{given}{ $_ } } (keys %{ $meta->{given} });
 
  my %opts;
  @opts{ @keys } = @$self{ @keys };
 
  $meta->{specified_opts} = \%opts;
 
  bless $meta->{specified_opts} => $class;
  weaken $meta->{specified_opts};
 
  $meta->{specified_opts};
}
 
#pod =head2 _complete_opts
#pod
#pod This method returns the opts object with all values, including those set by
#pod defaults.  It is probably not going to be very often-used.
#pod
#pod =cut

lib/Getopt/Long/Descriptive/Opts.pm  view on Meta::CPAN

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  # the keys to generate a class, but was undef; this wasn't a problem, but
  # broke tests of things that were relying on not-exists like tests of %$opt
  # contents or MooseX::Getopt which wanted to use things as args for new --
  # undef would not pass an Int TC.  Easier to just do this. -- rjbs,
  # 2009-11-27
  delete $copy->{$_} for grep { ! defined $copy->{$_} } keys %$copy;
 
  my $self = bless $copy => $new_class;
 
  $_CREATED_OPTS{ $new_class }{meta}{complete_opts} = $self;
  # weaken $_CREATED_OPTS{ $new_class }{meta}{complete_opts};
 
  return $self;
}
 
1;
 
__END__
 
=pod



( run in 0.374 second using v1.01-cache-2.11-cpan-bb97c1e446a )