Python的'argparse'在为长命名参数显示帮助文本时,会在新行上显示:
**#script.py -h
Select one of the options given
optional arguments:
-h, --help show this help message and exit
-bs , --business_service
choose the service << New line
-so , --service_offering
-ci , --cmdb_ci provide configuration item
-desc , --description
write description << New line
以下是我使用的代码:
self.parser = argparse.ArgumentParser(
description='Select one of the options given',
epilog=self._get_usage(),
formatter_class=argparse.RawTextHelpFormatter
)
self.parser.add_argument('-bs','--business_service',type=str,help='choose the service',metavar='')
self.parser.add_argument('-so','--service_offering',type=str,metavar='')
self.parser.add_argument('-ci','--mdcb_ci',type=str,help='provide configuration item',metavar='')
self.parser.add_argument('-desc','--description',type=str,help='write description',metavar='')
我希望帮助字符串和参数在同一行上:
-bs , --business_service choose the service << Same line
我该如何解决这个问题?