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 morden2k
Recipients morden2k
Date 2015-10-02.08:55:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1443776113.96.0.923054986589.issue25297@psf.upfronthosting.co.za>
In-reply-to
Content
Hi colleagues I have the code (max_help_position is 2000):

formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=2000)
parser = argparse.ArgumentParser(formatter_class=formatter_class)


subparsers = parser.add_subparsers(title="Commands", metavar="<command>")

cmd_parser = subparsers.add_parser('long_long_long_long_long_long_long',
                                   help='- jksljdalkjda',
                                   formatter_class=formatter_class)

args = parser.parse_args(['-h'])
print args

Result:

we have

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

Commands:
  <command>
    long_long_long_long_long_long_long
                                      - jksljdalkjda
    small                             - descr

instead

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

Commands:
  <command>
    long_long_long_long_long_long_long - jksljdalkjda
    small                              - descr

The code:

class MyFormatter(argparse.HelpFormatter):
    def __init__(self, prog):
        super(MyFormatter, self).__init__(prog, max_help_position=2000, width=2000)
        self._max_help_position = 2000
        self._action_max_length += 4

got same result.

The strings like:

formatter_class = lambda prog: argparse.HelpFormatter(prog,
                  max_help_position=2000, width=2000)

formatter_class = lambda prog: argparse.HelpFormatter(prog,
                  max_help_position=1000, width=2000)

formatter_class = lambda prog: argparse.HelpFormatter(prog,
                  max_help_position=2000, width=1000)

got same result: we always have new line after command.
History
Date User Action Args
2015-10-02 08:55:14morden2ksetrecipients: + morden2k
2015-10-02 08:55:13morden2ksetmessageid: <1443776113.96.0.923054986589.issue25297@psf.upfronthosting.co.za>
2015-10-02 08:55:13morden2klinkissue25297 messages
2015-10-02 08:55:13morden2kcreate