2 package MooseX::Getopt::Parser::Descriptive;
6 with 'MooseX::Getopt::Parser';
8 use Getopt::Long::Descriptive;
11 my ($class, $opt_spec) = @_;
12 return Getopt::Long::Descriptive::describe_options($class->_usage_format, @$opt_spec);
15 sub _get_getopt_spec {
16 my ($class, %params) = @_;
18 my (@options, %name_to_init_arg );
20 my $constructor_params = $params{params};
22 foreach my $opt ( @{ $params{options} } ) {
25 $opt->{doc} || ' ', # FIXME new GLD shouldn't need this hack
27 ( ( $opt->{required} && !exists($constructor_params->{$opt->{init_arg}}) ) ? (required => $opt->{required}) : () ),
29 # remove this 'feature' because it didn't work
30 # all the time, and so is better to not bother
31 # since Moose will handle the defaults just
34 #( exists $opt->{default} ? (default => $opt->{default}) : () ),
38 my $identifier = $opt->{name};
39 $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names
41 $name_to_init_arg{$identifier} = $opt->{init_arg};
44 return ( \@options, \%name_to_init_arg );
48 return "usage: %c %o";