Using python\'s optparse module I would like to add extra example lines below the regular usage output. My current help_print() output looks like this:
usage: ch
Another idea on how to do this would be disabling the default behavior for -h and printing your own help screen, which can include the default one:
from optparse import OptionParser
parser = OptionParser(add_help_option=False,
epilog="This can't be easily\n multilined")
parser.add_option('-h', '--help', dest='help', action='store_true',
help='show this help message and exit')
(options, args) = parser.parse_args()
if options.help:
parser.print_help()
print 'now we have an epilog'
print 'with as many lines as you wish'
sys.exit()
That is basically what the parser does with the default behavior of add_help_option=True, excluding of course the prints.
But, in all honesty, I'd also prefer a way to simply add any given number of description lines in the beginning and in the end.