Update OptionParser in all tools.

This commit is contained in:
Daniel Nichter
2011-08-12 09:05:46 -06:00
parent f23ca1af89
commit c7154acff1
24 changed files with 504 additions and 408 deletions

View File

@@ -148,6 +148,11 @@ sub get_specs {
$self->{DSNParser} = DSNParser->new(opts => \@dsn_opts);
}
if ( $contents =~ m/^(Percona Toolkit v.+)$/m ) {
$self->{version} = $1;
MKDEBUG && _d($self->{version});
}
return;
}
@@ -472,9 +477,12 @@ sub get_opts {
) or $self->save_error('Error parsing options');
if ( exists $self->{opts}->{version} && $self->{opts}->{version}->{got} ) {
printf("%s Ver %s Distrib %s Changeset %s\n",
$self->{program_name}, $main::VERSION, $main::DISTRIB, $main::SVN_REV)
or die "Cannot print: $OS_ERROR";
if ( $self->{version} ) {
print $self->{version}, "\n";
}
else {
print "Error parsing version. See the VERSION section of the tool's documentation.\n";
}
exit 0;
}
@@ -855,20 +863,6 @@ sub prompt_noecho {
return $response;
}
if ( MKDEBUG ) {
print '# ', $^X, ' ', $], "\n";
my $uname = `uname -a`;
if ( $uname ) {
$uname =~ s/\s+/ /g;
print "# $uname\n";
}
printf("# %s Ver %s Distrib %s Changeset %s line %d\n",
$PROGRAM_NAME, ($main::VERSION || ''), ($main::DISTRIB || ''),
($main::SVN_REV || ''), __LINE__);
print('# Arguments: ',
join(' ', map { my $a = "_[$_]_"; $a =~ s/\n/\n# /g; $a; } @ARGV), "\n");
}
sub _read_config_file {
my ( $self, $filename ) = @_;
open my $fh, "<", $filename or die "Cannot open $filename: $OS_ERROR\n";
@@ -1023,6 +1017,16 @@ sub _d {
print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
}
if ( MKDEBUG ) {
print '# ', $^X, ' ', $], "\n";
if ( my $uname = `uname -a` ) {
$uname =~ s/\s+/ /g;
print "# $uname\n";
}
print '# Arguments: ',
join(' ', map { my $a = "_[$_]_"; $a =~ s/\n/\n# /g; $a; } @ARGV), "\n";
}
1;
}
# ###########################################################################