mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Removed optional_value, made --version-check have default: off, updated the tools and documentation with the changes, and added the auto value to Pingback.pm
This commit is contained in:
@@ -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<IO::Socket::SSL> 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<IO::Socket::SSL> 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
|
||||
|
Reference in New Issue
Block a user