X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FGetopt%2FParser%2FLong.pm;h=70ad5a1534afc7af9dcd12f17d16335195765fd0;hb=5b582f22bdea267ebe6bd70c6cb664fdac30d20e;hp=a6a28000cda15ea4a15910089e53bb62dcaf48b9;hpb=c6c1f6285c8ad44ddb2375289ea449705bb467ad;p=gitmo%2FMooseX-Getopt.git diff --git a/lib/MooseX/Getopt/Parser/Long.pm b/lib/MooseX/Getopt/Parser/Long.pm index a6a2800..70ad5a1 100644 --- a/lib/MooseX/Getopt/Parser/Long.pm +++ b/lib/MooseX/Getopt/Parser/Long.pm @@ -27,28 +27,16 @@ sub build_options { unless $getopt->isa('MooseX::Getopt::Session'); my %options; - my @opts; foreach my $attr (@attrs) { my $name = $attr->name; - my $is_cmd = $attr->does('MooseX::Getopt::Meta::Attribute::Trait'); - - my $opt_string = $is_cmd && $attr->has_cmd_flag - ? $attr->cmd_flag - : $name; - - if ($is_cmd && $attr->has_cmd_aliases && scalar @{ $attr->cmd_aliases }) { - $opt_string .= '|' . join '|', @{ $attr->cmd_aliases }; - }; + my ($flag, @aliases) = $getopt->_get_cmd_flags_for_attr($attr); + my $type = $getopt->_get_cmd_type_for_attr($attr); - if ($is_cmd && $attr->has_cmd_type || $attr->has_type_constraint) { - my $type = $is_cmd && $attr->has_cmd_type ? $attr->cmd_type : $attr->type_constraint; - if (MooseX::Getopt::OptionTypeMap->has_option_type($type)) { - $opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type) - }; - }; + my $opt_string = join '|', $flag, @aliases; + $opt_string .= MooseX::Getopt::OptionTypeMap->get_option_type($type); $options{$name} = undef; push @opts, $opt_string => \$options{$name};