I use argparse to deal with input parameters, and it outputs the following with parser.print_help():
optional arguments:
-h, --help show this help message and exit
-t TEMPLATES, --templates TEMPLATES
template names to make, should be defined as section
name in conf, and have related file in templates/
folder
-c CONFPATH, --confpath CONFPATH
configuration path for template detail info
my code looks like the following:
import argparse
parser = argparse.ArgumentParser(prog='base_maker', description='template maker')
parser.add_argument('-t', '--templates', help='template names to make, should be defined as section name in conf, and have related file in templates/ folder', type=str)
parser.add_argument('-c', '--confpath', help='configuration path for template detail info', type=str, default=os.path.join(basepath, 'conf/maker.conf'))
However, I want to add a detailed example about how to use -t/--template, like (added in the example part):
optional arguments:
-h, --help show this help message and exit
-t TEMPLATES, --templates TEMPLATES
template names to make, should be defined as section
name in conf, and have related file in templates/
folder
-c CONFPATH, --confpath CONFPATH
configuration path for template detail info
example:
python test.py -t template/test.py
python test.py -t template/test -c conf/test.conf
python test.py -t test.py
I don't know which attribute should be used to add "example" part, I check Print program usage example with argparse modulen, but it's unclear and without detailed example when I check epilog in the official doc.
Could anyone give me a example about how to achieve that? Thanks