#33657: Customizable management command formatters.
-------------------------------------+-------------------------------------
     Reporter:  James Pic            |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Core (Management     |                  Version:  4.0
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * type:  Bug => Cleanup/optimization
 * easy:  0 => 1
 * stage:  Unreviewed => Accepted


Comment:

 It seems reasonable, to make it customizable by passing via `kwargs` to
 the [https://docs.djangoproject.com/en/4.0/howto/custom-management-
 commands/#django.core.management.BaseCommand.create_parser
 BaseCommand.create_parser() (as documented)]:
 {{{#!diff
 diff --git a/django/core/management/base.py
 b/django/core/management/base.py
 index f0e711ac76..52407807d8 100644
 --- a/django/core/management/base.py
 +++ b/django/core/management/base.py
 @@ -286,10 +286,10 @@ class BaseCommand:
          Create and return the ``ArgumentParser`` which will be used to
          parse the arguments to this command.
          """
 +        kwargs.setdefault("formatter_class", DjangoHelpFormatter)
          parser = CommandParser(
              prog="%s %s" % (os.path.basename(prog_name), subcommand),
              description=self.help or None,
 -            formatter_class=DjangoHelpFormatter,
              missing_args_message=getattr(self, "missing_args_message",
 None),
              called_from_command_line=getattr(self,
 "_called_from_command_line", None),
              **kwargs,
 }}}

 What do you think?

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701805f6f4ec5-a76951cd-7b4e-4c34-a4ee-2c2d9f5dd72e-000000%40eu-central-1.amazonses.com.

Reply via email to