mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Use new pretty --help.
This commit is contained in:
32
bin/pt-stalk
32
bin/pt-stalk
@@ -85,12 +85,34 @@ usage_or_errors() {
|
|||||||
echo
|
echo
|
||||||
echo "Command line options:"
|
echo "Command line options:"
|
||||||
echo
|
echo
|
||||||
for opt in $(ls "$PO_DIR"); do
|
perl -e '
|
||||||
local desc=$(cat $TMPDIR/po/$opt | grep '^desc:' | sed -e 's/^desc://')
|
use strict;
|
||||||
echo "--$opt"
|
use warnings FATAL => qw(all);
|
||||||
echo " $desc"
|
my $lcol = 20; # Allow this much space for option names.
|
||||||
|
my $rcol = 80 - $lcol; # The terminal is assumed to be 80 chars wide.
|
||||||
|
my $name;
|
||||||
|
while ( <> ) {
|
||||||
|
my $line = $_;
|
||||||
|
chomp $line;
|
||||||
|
if ( $line =~ s/^long:/ --/ ) {
|
||||||
|
$name = $line;
|
||||||
|
}
|
||||||
|
elsif ( $line =~ s/^desc:// ) {
|
||||||
|
$line =~ s/ +$//mg;
|
||||||
|
my @lines = grep { $_ }
|
||||||
|
$line =~ m/(.{0,$rcol})(?:\s+|\Z)/g;
|
||||||
|
if ( length($name) >= $lcol ) {
|
||||||
|
print $name, "\n", (q{ } x $lcol);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf "%-${lcol}s", $name;
|
||||||
|
}
|
||||||
|
print join("\n" . (q{ } x $lcol), @lines);
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' "$PO_DIR"/*
|
||||||
echo
|
echo
|
||||||
done
|
|
||||||
echo "Options and values after processing arguments:"
|
echo "Options and values after processing arguments:"
|
||||||
echo
|
echo
|
||||||
for opt in $(ls "$PO_DIR"); do
|
for opt in $(ls "$PO_DIR"); do
|
||||||
|
@@ -91,12 +91,34 @@ usage_or_errors() {
|
|||||||
echo
|
echo
|
||||||
echo "Command line options:"
|
echo "Command line options:"
|
||||||
echo
|
echo
|
||||||
for opt in $(ls "$PO_DIR"); do
|
perl -e '
|
||||||
local desc=$(cat $TMPDIR/po/$opt | grep '^desc:' | sed -e 's/^desc://')
|
use strict;
|
||||||
echo "--$opt"
|
use warnings FATAL => qw(all);
|
||||||
echo " $desc"
|
my $lcol = 20; # Allow this much space for option names.
|
||||||
|
my $rcol = 80 - $lcol; # The terminal is assumed to be 80 chars wide.
|
||||||
|
my $name;
|
||||||
|
while ( <> ) {
|
||||||
|
my $line = $_;
|
||||||
|
chomp $line;
|
||||||
|
if ( $line =~ s/^long:/ --/ ) {
|
||||||
|
$name = $line;
|
||||||
|
}
|
||||||
|
elsif ( $line =~ s/^desc:// ) {
|
||||||
|
$line =~ s/ +$//mg;
|
||||||
|
my @lines = grep { $_ }
|
||||||
|
$line =~ m/(.{0,$rcol})(?:\s+|\Z)/g;
|
||||||
|
if ( length($name) >= $lcol ) {
|
||||||
|
print $name, "\n", (q{ } x $lcol);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf "%-${lcol}s", $name;
|
||||||
|
}
|
||||||
|
print join("\n" . (q{ } x $lcol), @lines);
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' "$PO_DIR"/*
|
||||||
echo
|
echo
|
||||||
done
|
|
||||||
echo "Options and values after processing arguments:"
|
echo "Options and values after processing arguments:"
|
||||||
echo
|
echo
|
||||||
for opt in $(ls "$PO_DIR"); do
|
for opt in $(ls "$PO_DIR"); do
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
TESTS=72
|
TESTS=73
|
||||||
|
|
||||||
TMPFILE="$TEST_TMPDIR/parse-opts-output"
|
TMPFILE="$TEST_TMPDIR/parse-opts-output"
|
||||||
TOOL="pt-stalk"
|
TOOL="pt-stalk"
|
||||||
@@ -105,6 +105,10 @@ cmd_ok \
|
|||||||
"grep -q \"For more information, 'man pt-stalk' or 'perldoc\" $TMPFILE" \
|
"grep -q \"For more information, 'man pt-stalk' or 'perldoc\" $TMPFILE" \
|
||||||
"--help"
|
"--help"
|
||||||
|
|
||||||
|
cmd_ok \
|
||||||
|
"grep -q ' --string-opt2[ ]*String option with a default.' $TMPFILE" \
|
||||||
|
"Command line options"
|
||||||
|
|
||||||
cmd_ok \
|
cmd_ok \
|
||||||
"grep -q '\-\-string-opt[ ]*(No value)' $TMPFILE" \
|
"grep -q '\-\-string-opt[ ]*(No value)' $TMPFILE" \
|
||||||
"Options and values after processing arguments"
|
"Options and values after processing arguments"
|
||||||
|
Reference in New Issue
Block a user