Merged OptionParser-remove-optional_value & updated modules

This commit is contained in:
Brian Fraser
2012-11-09 13:31:13 -03:00
31 changed files with 1272 additions and 671 deletions

View File

@@ -57,7 +57,6 @@ sub new {
'default' => 1,
'cumulative' => 1,
'negatable' => 1,
'value_is_optional' => 1,
);
my $self = {
@@ -299,10 +298,9 @@ sub _parse_specs {
$opt->{short} = undef;
}
$opt->{is_negatable} = $opt->{spec} =~ m/!/ ? 1 : 0;
$opt->{is_cumulative} = $opt->{spec} =~ m/\+/ ? 1 : 0;
$opt->{optional_value} = $opt->{spec} =~ m/:/ ? 1 : 0;
$opt->{is_required} = $opt->{desc} =~ m/required/ ? 1 : 0;
$opt->{is_negatable} = $opt->{spec} =~ m/!/ ? 1 : 0;
$opt->{is_cumulative} = $opt->{spec} =~ m/\+/ ? 1 : 0;
$opt->{is_required} = $opt->{desc} =~ m/required/ ? 1 : 0;
$opt->{group} ||= 'default';
$self->{groups}->{ $opt->{group} }->{$long} = 1;
@@ -438,7 +436,7 @@ sub _set_option {
if ( $opt->{is_cumulative} ) {
$opt->{value}++;
}
elsif ( !($opt->{optional_value} && !$val) ) {
else {
$opt->{value} = $val;
}
$opt->{got} = 1;
@@ -979,12 +977,11 @@ sub _parse_size {
sub _parse_attribs {
my ( $self, $option, $attribs ) = @_;
my $types = $self->{types};
my $eq = $attribs->{'value_is_optional'} ? ':' : '=';
return $option
. ($attribs->{'short form'} ? '|' . $attribs->{'short form'} : '' )
. ($attribs->{'negatable'} ? '!' : '' )
. ($attribs->{'cumulative'} ? '+' : '' )
. ($attribs->{'type'} ? $eq . $types->{$attribs->{type}} : '' );
. ($attribs->{'type'} ? '=' . $types->{$attribs->{type}} : '' );
}
sub _parse_synopsis {