This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author derks
Recipients Brett.Hannigan, barry, bethard, derks, paul.j3
Date 2015-02-20.06:59:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1424415544.66.0.814822895603.issue22848@psf.upfronthosting.co.za>
In-reply-to
Content
I would like to add to this regarding the following:

[QUOTE]
Why would a user want to use `help=argparse.SUPPRESS`, as  opposed to simply omitting the `help` parameter?  The effect would be the same as your patch.
[/QUOTE]


This actually isn't the case, if you omit the 'help' option entirely, the sub-parser is still listed in the {short_list}.  For example:

    import argparse

    root_parser = argparse.ArgumentParser(prog='myapp')
    root_parser.add_argument('--foo', action=CustomAction)
    sub_parsers = root_parser.add_subparsers(dest='commands', title='subcommands')
    sub_parser = sub_parsers.add_parser('sub-command-1', help='useless help txt')
    sub_parser = sub_parsers.add_parser('sub-command-2', help=argparse.SUPPRESS)
    sub_parser = sub_parsers.add_parser('sub-command-3')

    args = root_parser.parse_args()


You end up with:

$ python argtest.py --help
usage: myapp [-h] [--foo FOO] {sub-command-1,sub-command-2,sub-command-3} ...

optional arguments:
  -h, --help            show this help message and exit
  --foo FOO

subcommands:
  {sub-command-1,sub-command-2,sub-command-3}
    sub-command-1       useless help txt
    sub-command-2       ==SUPPRESS==


The 'sub-command-3' is still listed in the {sub-parsers} .... where, if I want to hide a sub-parser... I don't want to see it anywhere.  Would be ideal to have a 'hide=True' option for sub-parsers and arguments alike.  All the same functionality, you just wouldn't see it in '--help'.
History
Date User Action Args
2015-02-20 06:59:04derkssetrecipients: + derks, barry, bethard, paul.j3, Brett.Hannigan
2015-02-20 06:59:04derkssetmessageid: <1424415544.66.0.814822895603.issue22848@psf.upfronthosting.co.za>
2015-02-20 06:59:04derkslinkissue22848 messages
2015-02-20 06:59:04derkscreate