Changing the metavar value in argparse only in argument listing and not in its Usage

后端 未结 2 743
情话喂你
情话喂你 2021-01-16 00:07

My question is similar to argparse help without duplicate ALLCAPS question.

Though i would explain in brief what that question was and what my question is:
I\'d

2条回答
  •  长发绾君心
    2021-01-16 00:58

    For a fast solution you can just set backspace character to a metavar.

    p.add_argument('-i', '--ini', help="use alternate ini file", metavar='\b')
    

    It will get you this:

    optional arguments:
      -h, --help         show this help message and exit
    

    If you want this:

      -i, --ini INI      use alternate ini file
    

    You will have to modify help formatter. Answered here python argparse help message, disable metavar for short options?

提交回复
热议问题