diff --git a/bin/pt-archiver b/bin/pt-archiver index 9f5ed755..77c04ba3 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -86,7 +86,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -328,10 +327,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; @@ -467,7 +465,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1008,12 +1006,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 { @@ -4820,17 +4817,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -5613,7 +5620,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( { dbh => $src->{dbh}, dsn => $src->{dsn} }, ( $dst ? { dbh => $dst->{dbh}, dsn => $dst->{dsn} } : () ), @@ -7050,14 +7057,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system; for the -latter case, you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 5a8f7896..bd2b92cd 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -85,7 +85,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -327,10 +326,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; @@ -466,7 +464,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1007,12 +1005,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 { @@ -3968,17 +3965,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -4346,7 +4353,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( map({ +{ dbh => $_->dbh, dsn => $_->dsn } } @cxn), { protocol => $o->get('version-check') }, @@ -4633,14 +4640,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-deadlock-logger b/bin/pt-deadlock-logger index 092fcac3..531914cc 100755 --- a/bin/pt-deadlock-logger +++ b/bin/pt-deadlock-logger @@ -83,7 +83,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -325,10 +324,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; @@ -464,7 +462,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1005,12 +1003,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 { @@ -3412,17 +3409,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -3855,7 +3862,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( { dbh => $dbh, dsn => $source_dsn }, ($dest_dsn ? { dbh => $dest_dsn, dsn => $dest_dsn } : ()), @@ -4547,14 +4554,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-diskstats b/bin/pt-diskstats index f67fc4a6..049ae4cf 100755 --- a/bin/pt-diskstats +++ b/bin/pt-diskstats @@ -85,7 +85,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -327,10 +326,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; @@ -466,7 +464,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1007,12 +1005,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 { @@ -4523,17 +4520,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -4835,7 +4842,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check({ protocol => $o->get('version-check') }); } @@ -5427,14 +5434,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 1d3f9866..16a948cd 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -987,7 +987,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -1229,10 +1228,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; @@ -1368,7 +1366,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1909,12 +1907,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 { @@ -4336,17 +4333,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -4675,7 +4682,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( {dbh => $dbh, dsn => $dsn}, { protocol => $o->get('version-check') }, @@ -5182,14 +5189,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-fifo-split b/bin/pt-fifo-split index 1f33b3e9..301fe3bf 100755 --- a/bin/pt-fifo-split +++ b/bin/pt-fifo-split @@ -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 { diff --git a/bin/pt-find b/bin/pt-find index 41770b2d..e75317a5 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -455,7 +455,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -697,10 +696,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; @@ -836,7 +834,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1377,12 +1375,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 { @@ -3176,17 +3173,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -3843,7 +3850,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( {dbh => $dbh, dsn => $dsn}, {protocol => $o->get('version-check')}, @@ -4300,14 +4307,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-fingerprint b/bin/pt-fingerprint index 1b975c28..b91ca3d5 100755 --- a/bin/pt-fingerprint +++ b/bin/pt-fingerprint @@ -58,7 +58,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -300,10 +299,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; @@ -439,7 +437,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -980,12 +978,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 { diff --git a/bin/pt-fk-error-logger b/bin/pt-fk-error-logger index 42a3719f..5bf778df 100755 --- a/bin/pt-fk-error-logger +++ b/bin/pt-fk-error-logger @@ -82,7 +82,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -324,10 +323,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; @@ -463,7 +461,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1004,12 +1002,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 { @@ -3116,17 +3113,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -3500,7 +3507,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( { dbh => $dbh, dsn => $src_dsn }, ($dst_dbh ? { dbh => $dst_dbh, dsn => $dst_dsn } : ()), @@ -3794,14 +3801,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index c281e30c..6774c4b5 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -818,7 +818,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -1060,10 +1059,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; @@ -1199,7 +1197,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1740,12 +1738,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 { @@ -4260,17 +4257,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -4963,7 +4970,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check({dbh => $dbh, dsn => $dsn}, { protocol => $o->get('version-check') }); } @@ -5696,14 +5703,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-index-usage b/bin/pt-index-usage index 0cae8d67..4be901d9 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -585,7 +585,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -827,10 +826,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; @@ -966,7 +964,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1507,12 +1505,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 { @@ -5842,17 +5839,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -6306,7 +6313,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( { dbh => $dbh, dsn => $dsn }, ($res_dbh ? { dbh => $res_dbh, dsn => $res_dsn } : ()), @@ -7225,14 +7232,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-kill b/bin/pt-kill index 8fecada9..b6a8df53 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -90,7 +90,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -332,10 +331,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; @@ -471,7 +469,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1012,12 +1010,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 { @@ -5851,17 +5848,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -6466,7 +6473,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( ($dbh ? { dbh => $dbh, dsn => $cxn->dsn() } : ()), { protocol => $o->get('version-check') }, @@ -7200,14 +7207,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-log-player b/bin/pt-log-player index 45906734..4fcd0b2d 100755 --- a/bin/pt-log-player +++ b/bin/pt-log-player @@ -62,7 +62,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -304,10 +303,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; @@ -443,7 +441,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -984,12 +982,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 { diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 770260ea..eb254b80 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -96,7 +96,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -338,10 +337,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; @@ -477,7 +475,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1018,12 +1016,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 { @@ -6873,17 +6870,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -7527,7 +7534,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( map({ +{ dbh => $_->dbh(), dsn => $_->dsn() } } $cxn, ($slaves ? @$slaves : ())), @@ -9863,14 +9870,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-query-advisor b/bin/pt-query-advisor index 770324b2..721f8bc4 100755 --- a/bin/pt-query-advisor +++ b/bin/pt-query-advisor @@ -466,7 +466,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -708,10 +707,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; @@ -847,7 +845,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1388,12 +1386,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 { @@ -7027,17 +7024,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -7685,7 +7692,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( ($review_dbh ? { dbh => $review_dbh, dsn => $review_dsn } : ()), ($dbh ? { dbh => $dbh, dsn => $dsn } : ()), @@ -8462,14 +8469,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 2c3fe96e..622b3184 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -604,7 +604,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -846,10 +845,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; @@ -985,7 +983,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1526,12 +1524,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 { @@ -12957,17 +12954,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -14566,7 +14573,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( ($qv_dbh ? { dbh => $qv_dbh, dsn => $review_dsn } : ()), ($ps_dbh ? { dbh => $ps_dbh, dsn => $ps_dsn } : ()), @@ -16957,14 +16964,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-show-grants b/bin/pt-show-grants index c3420870..d8249fe1 100755 --- a/bin/pt-show-grants +++ b/bin/pt-show-grants @@ -58,7 +58,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -300,10 +299,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; @@ -439,7 +437,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -980,12 +978,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 { diff --git a/bin/pt-slave-delay b/bin/pt-slave-delay index 6d7921bd..66afa9a7 100755 --- a/bin/pt-slave-delay +++ b/bin/pt-slave-delay @@ -83,7 +83,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -325,10 +324,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; @@ -464,7 +462,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1005,12 +1003,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 { @@ -3525,17 +3522,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -3893,7 +3900,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { my $tmp_master_dsn = $master_dsn ? $master_dsn : { h => $status->{master_host}, P => $status->{master_port} }; @@ -4377,14 +4384,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-slave-find b/bin/pt-slave-find index e6868b13..eb30fcf9 100755 --- a/bin/pt-slave-find +++ b/bin/pt-slave-find @@ -62,7 +62,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -304,10 +303,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; @@ -443,7 +441,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -984,12 +982,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 { diff --git a/bin/pt-slave-restart b/bin/pt-slave-restart index ee47ba94..2dc18c69 100755 --- a/bin/pt-slave-restart +++ b/bin/pt-slave-restart @@ -204,7 +204,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -446,10 +445,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; @@ -585,7 +583,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1126,12 +1124,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 { @@ -4148,17 +4145,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -4579,7 +4586,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( { dbh => $dbh, dsn => $dsn }, @servers_to_watch, { protocol => $o->get('version-check') }, @@ -5296,14 +5303,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index bad2d08e..c05ad255 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -1074,17 +1074,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -1752,7 +1762,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -1994,10 +2003,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; @@ -2133,7 +2141,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -2674,12 +2682,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 { @@ -8805,7 +8812,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( { dbh => $master_dbh, dsn => $master_dsn }, map({ +{ dbh => $_->dbh(), dsn => $_->dsn() } } @$slaves), @@ -11147,14 +11154,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 972fde5f..13239103 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -9765,7 +9765,7 @@ sub main { +{ dbh => $dbh, dsn => $dsn } } @dsns; - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check(@instances, { protocol => $o->get('version-check') }); } @@ -12278,14 +12278,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-tcp-model b/bin/pt-tcp-model index 8161b265..d85df9a2 100755 --- a/bin/pt-tcp-model +++ b/bin/pt-tcp-model @@ -61,7 +61,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -303,10 +302,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; @@ -442,7 +440,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -983,12 +981,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 { diff --git a/bin/pt-trend b/bin/pt-trend index 10f1946f..6a719b0a 100755 --- a/bin/pt-trend +++ b/bin/pt-trend @@ -61,7 +61,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -303,10 +302,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; @@ -442,7 +440,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -983,12 +981,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 { diff --git a/bin/pt-upgrade b/bin/pt-upgrade index 42e8042e..31c0236b 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -1006,7 +1006,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -1248,10 +1247,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; @@ -1387,7 +1385,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1928,12 +1926,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 { @@ -11324,17 +11321,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -11930,7 +11937,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( map({ +{ dbh => $_->{dbh}, dsn => $_->{dsn} } } @$hosts), { protocol => $o->get('version-check') }, @@ -12867,14 +12874,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/bin/pt-variable-advisor b/bin/pt-variable-advisor index a78295a9..a484e1a0 100755 --- a/bin/pt-variable-advisor +++ b/bin/pt-variable-advisor @@ -87,7 +87,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -329,10 +328,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; @@ -468,7 +466,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1009,12 +1007,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 { @@ -4437,17 +4434,27 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); @@ -4819,7 +4826,7 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->got('version-check') && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( ($dbh ? { dbh => $dbh, dsn => $dsn } : ()), { protocol => $o->get('version-check') }, @@ -5651,14 +5658,14 @@ Show version and exit. =item --version-check -type: string; value_is_optional: yes; default: https +type: string; default: off Send program versions to Percona and print suggested upgrades and problems. -If specified without a value, it will use https by default; However, this -might fail if C is not installed on your system, in which -case you may choose to use C<--version-check http>, which will forgo -encryption but should work out of the box. +Accepted values are https, http, off, and auto -- The latter tries both https +and http, in that order. Keep in mind that 'https' might fail if +C is not installed on your system, although +C<--version-check http> should work everywhere. The version check feature causes the tool to send and receive data from Percona over the web. The data contains program versions from the local diff --git a/lib/OptionParser.pm b/lib/OptionParser.pm index c61ab321..85c423da 100644 --- a/lib/OptionParser.pm +++ b/lib/OptionParser.pm @@ -107,7 +107,6 @@ sub new { 'default' => 1, 'cumulative' => 1, 'negatable' => 1, - 'value_is_optional' => 1, ); my $self = { @@ -414,10 +413,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; @@ -600,7 +598,7 @@ sub _set_option { if ( $opt->{is_cumulative} ) { $opt->{value}++; } - elsif ( !($opt->{optional_value} && !$val) ) { + else { $opt->{value} = $val; } $opt->{got} = 1; @@ -1275,12 +1273,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 { diff --git a/lib/Pingback.pm b/lib/Pingback.pm index 087a3c48..dea42ae4 100644 --- a/lib/Pingback.pm +++ b/lib/Pingback.pm @@ -87,17 +87,31 @@ sub version_check { return; } - my $protocol = $args->{protocol} || 'https'; - my $advice = pingback( - url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", - instances => $instances_to_check, - protocol => $args->{protocol}, - ); + # We got here if the protocol wasn't "off", but we haven't validated + # other possible values. I don't want it to die here, so if it isn't + # https or http, assume that it's 'auto'. + $args->{protocol} ||= 'https'; + my @protocols = $args->{protocol} ne 'https' && $args->{protocol} ne 'http' + ? qw(https http) + : $args->{protocol}; + my $advice; + my $e; + for my $protocol ( @protocols ) { + $advice = eval { pingback( + url => $ENV{PERCONA_VERSION_CHECK_URL} || "$protocol://v.percona.com", + instances => $instances_to_check, + protocol => $protocol, + ) }; + # No advice, and no error, so no reason to keep trying. + last if !$advice && !$EVAL_ERROR; + $e ||= $EVAL_ERROR; + } if ( $advice ) { print "# Percona suggests these upgrades:\n"; print join("\n", map { "# * $_" } @$advice), "\n\n"; } else { + die $e if $e; print "# No suggestions at this time.\n\n"; ($ENV{PTVCDEBUG} || PTDEBUG ) && _d('--version-check worked, but there were no suggestions'); diff --git a/t/lib/OptionParser.t b/t/lib/OptionParser.t index 303e07ce..95c47028 100644 --- a/t/lib/OptionParser.t +++ b/t/lib/OptionParser.t @@ -145,7 +145,6 @@ is_deeply( type => 's', got => 0, value => undef, - optional_value => 0, }, 'port' => { spec => 'port|p=i', @@ -159,7 +158,6 @@ is_deeply( type => 'i', got => 0, value => undef, - optional_value => 0, }, 'price' => { spec => 'price=f', @@ -173,7 +171,6 @@ is_deeply( type => 'f', got => 0, value => undef, - optional_value => 0, }, 'hash-req' => { spec => 'hash-req=s', @@ -187,7 +184,6 @@ is_deeply( type => 'H', got => 0, value => undef, - optional_value => 0, }, 'hash-opt' => { spec => 'hash-opt=s', @@ -201,7 +197,6 @@ is_deeply( type => 'h', got => 0, value => undef, - optional_value => 0, }, 'array-req' => { spec => 'array-req=s', @@ -215,7 +210,6 @@ is_deeply( type => 'A', got => 0, value => undef, - optional_value => 0, }, 'array-opt' => { spec => 'array-opt=s', @@ -229,7 +223,6 @@ is_deeply( type => 'a', got => 0, value => undef, - optional_value => 0, }, 'host' => { spec => 'host=s', @@ -243,7 +236,6 @@ is_deeply( type => 'd', got => 0, value => undef, - optional_value => 0, }, 'chunk-size' => { spec => 'chunk-size=s', @@ -257,7 +249,6 @@ is_deeply( type => 'z', got => 0, value => undef, - optional_value => 0, }, 'time' => { spec => 'time=s', @@ -271,7 +262,6 @@ is_deeply( type => 'm', got => 0, value => undef, - optional_value => 0, }, 'help' => { spec => 'help+', @@ -285,7 +275,6 @@ is_deeply( type => undef, got => 0, value => undef, - optional_value => 0, }, 'other' => { spec => 'other!', @@ -299,7 +288,6 @@ is_deeply( type => undef, got => 0, value => undef, - optional_value => 0, } }, 'Parse opt specs' @@ -520,7 +508,6 @@ is_deeply( type => undef, got => 0, value => undef, - optional_value => 0, }, 'defaultset' => { spec => 'defaultset!', @@ -536,7 +523,6 @@ is_deeply( type => undef, got => 0, value => undef, - optional_value => 0, }, 'defaults-file' => { spec => 'defaults-file|F=s', @@ -550,7 +536,6 @@ is_deeply( type => 's', got => 0, value => undef, - optional_value => 0, }, 'dog' => { spec => 'dog|D=s', @@ -564,7 +549,6 @@ is_deeply( type => 's', got => 0, value => undef, - optional_value => 0, }, 'love' => { spec => 'love|l+', @@ -578,7 +562,6 @@ is_deeply( type => undef, got => 0, value => undef, - optional_value => 0, }, }, 'Parse dog specs' @@ -978,7 +961,6 @@ is_deeply( long => 'bar', type => undef, parsed => 1, - optional_value=> 0, }, 'Disabled opt is not destroyed' ); @@ -2008,55 +1990,13 @@ $o->get_opts(); $output = output( sub { $o->usage_or_errors(undef, 1); }, ); +$synop{usage} =~ s/([\[\]])/\\$1/g; like( $output, - qr/^$synop{description} For more details.+\nUsage: \Q$synop{usage}\E\n?$/m, + qr/^$synop{description} For more details.+\nUsage: $synop{usage}$/m, "Uses desc and usage from SYNOPSIS for help" ); -# Add a value_is_optional option -@ARGV = qw(); -$o->get_opts(); - -ok( - !$o->got('version-check'), - "version-check is not true by default" -); - -is( - $o->get('version-check'), - "https", - "..but it still has a value", -); - -@ARGV = qw(--version-check); -$o->get_opts(); - -ok( - $o->got('version-check'), - "version-check is true if specified without arguments" -); - -is( - $o->get('version-check'), - "https", - "..and has the default value", -); - -@ARGV = qw(--version-check http); -$o->get_opts(); - -ok( - $o->got('version-check'), - "version-check is true if specified with arguments" -); - -is( - $o->get('version-check'), - "http", - "..and has the specified value", -); - # ############################################################################# # Bug 1039074: Tools exit 0 on error parsing options, should exit non-zero # ############################################################################# @@ -2094,3 +2034,4 @@ like( ); done_testing; +exit; diff --git a/t/pt-query-digest/version_check.t b/t/pt-query-digest/version_check.t index ab54756c..be1fbb61 100644 --- a/t/pt-query-digest/version_check.t +++ b/t/pt-query-digest/version_check.t @@ -109,6 +109,19 @@ ok( "percona-toolkit-version-check file not created with --no-version-check" ); +$output = `PTVCDEBUG=1 $cmd --version-check off @args 2>&1`; + +unlike( + $output, + qr/(?:VersionCheck|Pingback|Percona suggests)/, + "Looks like --version-check off disabled the version-check" +) or diag($output); + +ok( + !-f $check_time_file, + "percona-toolkit-version-check file not created with --version-check off" +); + # PERCONA_VERSION_CHECK=0 is handled in Pingback, so it will print a line # for PTVCDEBUG saying why it didn't run. So we just check that it doesn't # create the file which also signifies that it didn't run.