1 package MooseX::Getopt::GLD;
5 around '_getopt_spec' => sub {
9 return $self->_gld_spec(@_);
10 # Ignore $orig, code for _gld_spec here
13 around '_get_options' => sub {
17 my ($params, $opt_spec) = @_;
18 return Getopt::Long::Descriptive::describe_options(
19 $class->_usage_format(%$params), @$opt_spec
25 my ( $class, %params ) = @_;
27 my ( @options, %name_to_init_arg );
29 my $constructor_params = $params{params};
31 foreach my $opt ( @{ $params{options} } ) {
34 $opt->{doc} || ' ', # FIXME new GLD shouldn't need this hack
36 ( ( $opt->{required} && !exists($constructor_params->{$opt->{init_arg}}) ) ? (required => $opt->{required}) : () ),
38 # remove this 'feature' because it didn't work
39 # all the time, and so is better to not bother
40 # since Moose will handle the defaults just
43 #( exists $opt->{default} ? (default => $opt->{default}) : () ),
47 my $identifier = $opt->{name};
48 $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names
50 $name_to_init_arg{$identifier} = $opt->{init_arg};
53 return ( \@options, \%name_to_init_arg );
64 MooseX::Getopt::GLD - role to implement specific functionality for
65 L<Getopt::Long::Descriptive>
73 This is a role for C<MooseX::Getopt>.
85 All complex software has bugs lurking in it, and this module is no
86 exception. If you find a bug please either email me, or add the bug
91 Dagfinn Ilmari MannsE<aring>ker E<lt>ilmari@ilmari.orgE<gt>
93 Stevan Little E<lt>stevan@iinteractive.comE<gt>
95 Yuval Kogman C<< <nuffin@cpan.org> >>
97 =head1 COPYRIGHT AND LICENSE
99 Copyright 2007-2008 by Infinity Interactive, Inc.
101 L<http://www.iinteractive.com>
103 This library is free software; you can redistribute it and/or modify
104 it under the same terms as Perl itself.