Use new pretty --help.

This commit is contained in:
Daniel Nichter
2012-01-26 12:59:48 -07:00
parent 05ac0be136
commit 6b017da6fe
3 changed files with 61 additions and 13 deletions

View File

@@ -85,12 +85,34 @@ usage_or_errors() {
echo
echo "Command line options:"
echo
for opt in $(ls "$PO_DIR"); do
local desc=$(cat $TMPDIR/po/$opt | grep '^desc:' | sed -e 's/^desc://')
echo "--$opt"
echo " $desc"
echo
done
perl -e '
use strict;
use warnings FATAL => qw(all);
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 "Options and values after processing arguments:"
echo
for opt in $(ls "$PO_DIR"); do