[New-bugs-announce] [issue34046] subparsers -> add_parser doesn't support hyphen char '-'
Nir Barel
report at bugs.python.org
Wed Jul 4 12:19:59 EDT 2018
New submission from Nir Barel <nir_barel at bmc.com>:
parent_parser = argparse.ArgumentParser(add_help=False)
main_parser = argparse.ArgumentParser(prog='app_cli')
service_subparsers = main_parser.add_subparsers(title="service", dest="service_command", )
service_parser = service_subparsers.add_parser("-dr", help="sample help", parents=[parent_parser])
service_parser.add_argument("-old_host",help="my old host", dest="oldHost", required=False)
args = main_parser.parse_args()
when I try to run the app_cli -dr I am getting an error "error:unrecognized arguments: -dr"
when I try to run the app_cli with -dr -h I am getting the help of the main application and not the help of the service subparser
only if I change '-dr' to 'dr' it works as expected, but I need to support the hyphen for all arguments
----------
components: Library (Lib)
messages: 321057
nosy: nir_barel at bmc.com
priority: normal
severity: normal
status: open
title: subparsers -> add_parser doesn't support hyphen char '-'
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34046>
_______________________________________
More information about the New-bugs-announce
mailing list