mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 07:30:02 +00:00
Merged OptionParser-remove-optional_value & updated modules
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user