[issue29626] Issue with spacing in argparse module while using help

Falguniben Jhaveri report at bugs.python.org
Mon Feb 27 17:07:31 EST 2017


Falguniben Jhaveri added the comment:

Sample code to repro this:

import argparse

    parser = argparse.ArgumentParser(prog='cli')
    subparsers = parser.add_subparsers(dest="command")

    subparsers_user_delete = subparsers.add_parser("delete", help="Deletes a user in your organization.",
                                                        description="Deletes a user in your organization.")
    subparsers_user_delete.add_argument("userid", help="The userid of user.", default=None, type=int)
    subparsers_user_delete.add_argument("-p", "--projectid", metavar="",
                                        help="Specify the project ID of project from where you want to delete"
                                             " the user or else user will be deleted from organization.", type=int,
                                        default=None)

    parser_nodes = subparsers.add_parser('nodes')
    sp = parser_nodes.add_subparsers()
    p1 = sp.add_parser('list', description='Lists nodes in your current project')
    p1.add_argument('-p', '--projectid', action='store_true')
    p1.add_argument('-o', '--org', action='store_true', help=' (For administrators only) Lists all the nodes in')
    parser.parse_args()

Please run following command:
$issue.py delete -h

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29626>
_______________________________________


More information about the Python-bugs-list mailing list