I have the following code:
parser = argparse.ArgumentParser(description='Postfix Queue Administration Tool',
prog='pqa',
usage='%(prog)s [-h] [-v,--version]')
parser.add_argument('-l', '--list', action='store_true',
help='Shows full overview of all queues')
parser.add_argument('-q', '--queue', action='store', metavar='<queue>', dest='queue',
help='Show information for <queue>')
parser.add_argument('-d', '--domain', action='store', metavar='<domain>', dest='domain',
help='Show information about a specific <domain>')
parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.1')
args = parser.parse_args()
Which gives me output like this:
%./pqa
usage: pqa [-h] [-v,--version]
Postfix Queue Administration Tool
optional arguments:
-h, --help show this help message and exit
-l, --list Shows full overview of all queues
-q <queue>, --queue <queue>
Show information for <queue>
-d <domain>, --domain <domain>
Show information about a specific <domain>
-v, --version show program's version number and exit
I would very much like to know how I can 'group' commands that have two versions (ie. long options) which each also show a metavar.
This is mostly an aesthetic issue on my side, but I would still like to fix this. I have been reading manuals and texts on the internet, but either the information just isn't there or I am totally missing something here :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…