1

Is it possible to add to the automatic output generated by argparse for the -h (help) option?

I'm happy with what it does automagically, but would also like to append a paragraph or two giving a short summary and some examples, a bit like a typical man page.

1 Answer 1

1

The description parameter of the ArgumentParser object can be used to place text between usage and argument help. The epilog parameter adds text after the argument help.

Use RawDescriptionHelpFormatter to get multiline strings.

import argparse description = """Some description. Another line. """ epilog = """Some epilog. Another line. """ parser = argparse.ArgumentParser(description=description, epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--someArgument', help='Argument description.') args = parser.parse_args() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.