mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #29301 -- Made management command --help display command-specific arguments before common arguments.
This commit is contained in:
parent
2919a08c20
commit
c3055242c8
@ -228,6 +228,9 @@ class BaseCommand:
|
||||
self, prog="%s %s" % (os.path.basename(prog_name), subcommand),
|
||||
description=self.help or None,
|
||||
)
|
||||
# Add command-specific arguments first so that they appear in the
|
||||
# --help output before arguments common to all commands.
|
||||
self.add_arguments(parser)
|
||||
parser.add_argument('--version', action='version', version=self.get_version())
|
||||
parser.add_argument(
|
||||
'-v', '--verbosity', action='store', dest='verbosity', default=1,
|
||||
@ -251,7 +254,6 @@ class BaseCommand:
|
||||
'--no-color', action='store_true', dest='no_color',
|
||||
help="Don't colorize the command output.",
|
||||
)
|
||||
self.add_arguments(parser)
|
||||
return parser
|
||||
|
||||
def add_arguments(self, parser):
|
||||
|
@ -1495,6 +1495,13 @@ class CommandTypes(AdminScriptTestCase):
|
||||
args = ['check', '--help']
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(err)
|
||||
# Command-specific options like --tag appear before options common to
|
||||
# all commands like --version.
|
||||
tag_location = out.find('--tag')
|
||||
version_location = out.find('--version')
|
||||
self.assertNotEqual(tag_location, -1)
|
||||
self.assertNotEqual(version_location, -1)
|
||||
self.assertLess(tag_location, version_location)
|
||||
self.assertOutput(out, "Checks the entire Django project for potential problems.")
|
||||
|
||||
def test_color_style(self):
|
||||
|
Loading…
Reference in New Issue
Block a user