New submission from Nir Barel <nir_ba...@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_ba...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue34046>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to