Message321057
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 |
|
Date |
User |
Action |
Args |
2018-07-04 16:19:59 | nir_barel@bmc.com | set | recipients:
+ nir_barel@bmc.com |
2018-07-04 16:19:59 | nir_barel@bmc.com | set | messageid: <1530721199.23.0.56676864532.issue34046@psf.upfronthosting.co.za> |
2018-07-04 16:19:59 | nir_barel@bmc.com | link | issue34046 messages |
2018-07-04 16:19:59 | nir_barel@bmc.com | create | |
|