1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#!/usr/bin/perl -w
# Postprocess grib_api's help messages, which are almost man pages
my $name = shift @ARGV;
sub escapeslashes($)
{
my $str = shift;
$str =~ s/-/\\-/g;
return $str;
}
print ".TH ".uc($name)." \"1\" \"April 2009\" \"".lc($name)."\" \"User Commands\"\n";
while (<>)
{
if (/^[A-Z]/)
{
# Sections
s/\s+(.+)$/\n$1/;
s/^/.SH /;
print;
} elsif (/^\t-/) {
# Options
print ".TP\n";
s/^\s*//;
s/(\S+)/"\\fB".escapeslashes($1)."\\fR"/e ;
print;
} elsif (/^\t/) {
s/^\s*//;
print;
} else {
print;
}
}
print ".SH AUTHOR\n";
print "This manpage has been autogenerated by Enrico Zini <enrico\@debian.org>";
print "from the command line help of $name.\n";
|