~percona-toolkit-dev/percona-toolkit/fix-887638-ptqa-negative-at-byte

« back to all changes in this revision

Viewing changes to bin/pt-trend

Merged OptionParser-remove-optional_value & updated modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
      'default'    => 1,
62
62
      'cumulative' => 1,
63
63
      'negatable'  => 1,
64
 
      'value_is_optional' => 1,
65
64
   );
66
65
 
67
66
   my $self = {
303
302
            $opt->{short} = undef;
304
303
         }
305
304
 
306
 
         $opt->{is_negatable}   = $opt->{spec} =~ m/!/        ? 1 : 0;
307
 
         $opt->{is_cumulative}  = $opt->{spec} =~ m/\+/       ? 1 : 0;
308
 
         $opt->{optional_value} = $opt->{spec} =~ m/:/        ? 1 : 0;
309
 
         $opt->{is_required}    = $opt->{desc} =~ m/required/ ? 1 : 0;
 
305
         $opt->{is_negatable}  = $opt->{spec} =~ m/!/        ? 1 : 0;
 
306
         $opt->{is_cumulative} = $opt->{spec} =~ m/\+/       ? 1 : 0;
 
307
         $opt->{is_required}   = $opt->{desc} =~ m/required/ ? 1 : 0;
310
308
 
311
309
         $opt->{group} ||= 'default';
312
310
         $self->{groups}->{ $opt->{group} }->{$long} = 1;
442
440
   if ( $opt->{is_cumulative} ) {
443
441
      $opt->{value}++;
444
442
   }
445
 
   elsif ( !($opt->{optional_value} && !$val) ) {
 
443
   else {
446
444
      $opt->{value} = $val;
447
445
   }
448
446
   $opt->{got} = 1;
983
981
sub _parse_attribs {
984
982
   my ( $self, $option, $attribs ) = @_;
985
983
   my $types = $self->{types};
986
 
   my $eq    = $attribs->{'value_is_optional'} ? ':' : '=';
987
984
   return $option
988
985
      . ($attribs->{'short form'} ? '|' . $attribs->{'short form'}   : '' )
989
986
      . ($attribs->{'negatable'}  ? '!'                              : '' )
990
987
      . ($attribs->{'cumulative'} ? '+'                              : '' )
991
 
      . ($attribs->{'type'}       ? $eq . $types->{$attribs->{type}} : '' );
 
988
      . ($attribs->{'type'}       ? '=' . $types->{$attribs->{type}} : '' );
992
989
}
993
990
 
994
991
sub _parse_synopsis {