mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Fix --help description interpolation.
This commit is contained in:
@@ -128,20 +128,20 @@ parse_options() {
|
||||
my $opt = $1;
|
||||
my $file = "$ENV{PO_DIR}/$opt";
|
||||
open my $opt_fh, ">", $file or die "Cannot open $file: $!";
|
||||
printf $opt_fh "long:$opt\n";
|
||||
print $opt_fh "long:$opt\n";
|
||||
$para = <>;
|
||||
chomp;
|
||||
if ( $para =~ m/^[a-z ]+:/ ) {
|
||||
map {
|
||||
chomp;
|
||||
my ($attrib, $val) = split(/: /, $_);
|
||||
printf $opt_fh "$attrib:$val\n";
|
||||
print $opt_fh "$attrib:$val\n";
|
||||
} split(/; /, $para);
|
||||
$para = <>;
|
||||
chomp;
|
||||
}
|
||||
my ($desc) = $para =~ m/^([^?.]+)/;
|
||||
printf $opt_fh "desc:$desc.\n";
|
||||
print $opt_fh "desc:$desc.\n";
|
||||
close $opt_fh;
|
||||
}
|
||||
}
|
||||
|
@@ -137,20 +137,20 @@ parse_options() {
|
||||
my $opt = $1;
|
||||
my $file = "$ENV{PO_DIR}/$opt";
|
||||
open my $opt_fh, ">", $file or die "Cannot open $file: $!";
|
||||
printf $opt_fh "long:$opt\n";
|
||||
print $opt_fh "long:$opt\n";
|
||||
$para = <>;
|
||||
chomp;
|
||||
if ( $para =~ m/^[a-z ]+:/ ) {
|
||||
map {
|
||||
chomp;
|
||||
my ($attrib, $val) = split(/: /, $_);
|
||||
printf $opt_fh "$attrib:$val\n";
|
||||
print $opt_fh "$attrib:$val\n";
|
||||
} split(/; /, $para);
|
||||
$para = <>;
|
||||
chomp;
|
||||
}
|
||||
my ($desc) = $para =~ m/^([^?.]+)/;
|
||||
printf $opt_fh "desc:$desc.\n";
|
||||
print $opt_fh "desc:$desc.\n";
|
||||
close $opt_fh;
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ use PerconaTest;
|
||||
my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/;
|
||||
push @ARGV, "$trunk/t/lib/bash/*.sh" unless @ARGV;
|
||||
|
||||
$ENV{BIN_DIR} = "$trunk/bin";
|
||||
$ENV{LIB_DIR} = "$trunk/lib/bash";
|
||||
$ENV{T_LIB_DIR} = "$trunk/t/lib";
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TESTS=26
|
||||
TESTS=27
|
||||
|
||||
TMPFILE="$TEST_TMPDIR/parse-opts-output"
|
||||
|
||||
@@ -81,6 +81,14 @@ cmd_ok \
|
||||
"grep -q \"For more information, 'man pt-stalk' or 'perldoc\" $TMPFILE" \
|
||||
"--help"
|
||||
|
||||
# Don't interpolate.
|
||||
parse_options "$T_LIB_DIR/samples/bash/po003.sh" --help
|
||||
usage_or_errors "$T_LIB_DIR/samples/bash/po003.sh" >$TMPFILE 2>&1
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'Exit if the disk is less than this %full.' $TMPFILE" \
|
||||
"Don't interpolate --help descriptions"
|
||||
|
||||
# ############################################################################
|
||||
# Done
|
||||
# ############################################################################
|
||||
|
37
t/lib/samples/bash/po003.sh
Normal file
37
t/lib/samples/bash/po003.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
:
|
||||
|
||||
# ############################################################################
|
||||
# Documentation
|
||||
# ############################################################################
|
||||
:<<'DOCUMENTATION'
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
pt-stalk - Wait for a condition to occur then begin collecting data.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over
|
||||
|
||||
=item --disk-pct-limit
|
||||
|
||||
type: int; default: 5
|
||||
|
||||
Exit if the disk is less than this %full.
|
||||
|
||||
=item --help
|
||||
|
||||
Print help.
|
||||
|
||||
=back
|
||||
|
||||
=head1 ENVIRONMENT
|
||||
|
||||
No env vars used.
|
||||
|
||||
=cut
|
||||
|
||||
DOCUMENTATION
|
Reference in New Issue
Block a user