X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FGetopt.pm;h=86c5904a83e85d76a3d40d259c8199e904c182c9;hb=de75868f0e8c3865b3f207b7ea84920760a6c8d3;hp=e6e07a15ac9323e31621937d9d7c37eb26ed0cc2;hpb=8034a2324bcef31b91a45a83baec1508acee2763;p=gitmo%2FMooseX-Getopt.git diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index e6e07a1..86c5904 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -16,21 +16,27 @@ sub new_with_options { my (@options, %name_to_init_arg); foreach my $attr ($class->meta->compute_all_applicable_attributes) { my $name = $attr->name; - - if ($attr->isa('MooseX::Getopt::Meta::Attribute') && $attr->has_cmd_flag) { - $name = $attr->cmd_flag; + my $aliases; + + if ($attr->isa('MooseX::Getopt::Meta::Attribute')) { + $name = $attr->cmd_flag if $attr->has_cmd_flag; + $aliases = $attr->cmd_aliases if $attr->has_cmd_aliases; } $name_to_init_arg{$name} = $attr->init_arg; + my $opt_string = $aliases + ? join(q{|}, $name, @$aliases) + : $name; + if ($attr->has_type_constraint) { my $type_name = $attr->type_constraint->name; if (MooseX::Getopt::OptionTypeMap->has_option_type($type_name)) { - $name .= MooseX::Getopt::OptionTypeMap->get_option_type($type_name); + $opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type_name); } } - push @options => $name; + push @options => $opt_string; } my %options;