Contact me sending an e-mail (antispam defense activated) |
Generate a skel for manpage from "prog --help"Sandro Tosi, 04 August 2006
In my role as Debian packages maintainer, I have to provide a good package, and this could mean to write a manpage if the upstream author does not provide one. It's common to have a tool that invoked with -h or --help switch generates a list of its options with their meaning. The following script takes the output of "prog --help" and generate a skeleton for options part of a manpage (anymeal is the program I was packaging while writing this script): anymeal --help-all | grep "^ -" | sed 's/ -/.TP \ .B -/' | sed 's| --| \\-\\-|g' | sed 's| -| \\-|g' note the space in the grep command and in the substitution part for sed: adjust for the output. Here is chunk of the output of anymeal --help-all: --help
Show help about options and the trasformation applyied by the script: .TP now, you are only left to take the description in the row below ".B ..." and you've done. If you have installed the package man-db, you can find some examples of man pages in the directory /usr/share/doc/man-db/examples/. On 2006-08-19 I've discovered the tool help2man, that does almost the same thing... |