[Django] #33657: Custom command help formatting destroyed

3 views
Skip to first unread message

Django

unread,
Apr 22, 2022, 1:39:41 PM4/22/22
to django-...@googlegroups.com
#33657: Custom command help formatting destroyed
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: 4.0
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
With code like:

{{{
class Command(BaseCommand):
help = '''
Import a contract from tzkt.

Example usage:

./manage.py tzkt_import 'Tezos Mainnet'
KT1HTDtMBRCKoNHjfWEEvXneGQpCfPAt6BRe
'''
}}}

Help output is:


{{{
$ ./manage.py help tzkt_import
usage: manage.py tzkt_import [-h] [--api API] [--version] [-v {0,1,2,3}]
[--settings SETTINGS]
[--pythonpath PYTHONPATH] [--traceback]
[--no-color] [--force-color]
[--skip-checks]
blockchain target

Import a contract from tzkt Example usage: ./manage.py tzkt_import 'Tezos
Mainnet'
KT1HTDtMBRCKoNHjfWEEvXneGQpCfPAt6BRe

positional arguments:
blockchain Name of the blockchain to import into
target Id of the contract to import

}}}

When that was expected:

{{{
$ ./manage.py help tzkt_import
usage: manage.py tzkt_import [-h] [--api API] [--version] [-v {0,1,2,3}]
[--settings SETTINGS]
[--pythonpath PYTHONPATH] [--traceback]
[--no-color] [--force-color]
[--skip-checks]
blockchain target

Import a contract from tzkt

Example usage:

./manage.py tzkt_import 'Tezos Mainnet'
KT1HTDtMBRCKoNHjfWEEvXneGQpCfPAt6BRe


positional arguments:
blockchain Name of the blockchain to import into
target Id of the contract to import
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33657>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 22, 2022, 2:27:24 PM4/22/22
to django-...@googlegroups.com
#33657: Custom command help formatting destroyed
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 4.0
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

This seems no fault of Django but is rather
[https://docs.python.org/3/library/argparse.html#formatter-class the
default behavior] of `ArgumentParser` ("By default, `ArgumentParser`
objects line-wrap the description and epilog texts in command-line help
messages"). This can be changed by using a custom
[https://github.com/django/django/blob/ed0a2c3238aa0b9c0d01c436d5bcd70930d696b0/django/core/management/base.py#L292
formatter_class], though Django already specifies a custom one
([https://github.com/django/django/blob/ed0a2c3238aa0b9c0d01c436d5bcd70930d696b0/django/core/management/base.py#L105-L131
DjangoHelpFormatter]).

--
Ticket URL: <https://code.djangoproject.com/ticket/33657#comment:1>

Reply all
Reply to author
Forward
0 new messages