Skip to content

Commit

Permalink
Renamed --structured to --separatelogs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Aug 7, 2021
1 parent 3e4cb20 commit 4ace319
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions django/core/management/commands/makemigrations.py
Expand Up @@ -58,8 +58,8 @@ def add_arguments(self, parser):
help='Exit with a non-zero status if model changes are missing migrations.',
)
parser.add_argument(
'--structured', action='store_true', dest='structured_output',
help='Output only created migration filepaths to stdout; all other logging to stderr.',
'--separatelogs', action='store_true', dest='separate_logs',
help='Output only created migration filepaths to stdout; divert other logging to stderr.',
)

@no_translations
Expand All @@ -74,8 +74,8 @@ def handle(self, *app_labels, **options):
raise CommandError('The migration name must be a valid Python identifier.')
self.include_header = options['include_header']
check_changes = options['check_changes']
self.structured_output = options['structured_output']
if self.structured_output:
self.separate_logs = options['separate_logs']
if self.separate_logs:
self.log = self.stderr
else:
self.log = self.stdout
Expand Down Expand Up @@ -224,7 +224,7 @@ def write_migration_files(self, changes):
self.log.write(' %s\n' % self.style.MIGRATE_LABEL(migration_string))
for operation in migration.operations:
self.log.write(' - %s' % operation.describe())
if self.structured_output:
if self.separate_logs:
self.stdout.write(migration_string + '\n')
if not self.dry_run:
# Write the migrations file to the disk.
Expand Down
6 changes: 3 additions & 3 deletions docs/ref/django-admin.txt
Expand Up @@ -837,10 +837,10 @@ migrations are detected.
connection was added. In that case, check for a consistent migration
history is skipped.

.. django-admin-option:: --structured
.. django-admin-option:: --separatelogs

Diverts log output of ``makemigrations`` to stderr and writes only paths of
generated migration files to stdout.
Diverts log output of ``makemigrations`` to ``stderr`` and writes only paths
of generated migration files to ``stdout``.

.. versionadded:: 4.0

Expand Down
6 changes: 3 additions & 3 deletions docs/releases/4.0.txt
Expand Up @@ -269,9 +269,9 @@ Management Commands
As a consequence, ``readline`` is no longer loaded if running in *isolated*
mode.

* :djadmin:`makemigrations` can now be called with ``--structured`` to divert
logging to stderr and produce only structured output to stdout consisting
of the paths of generated migration files.
* The :djadmin:`makemigrations` command can now be called with
:option:`--separatelogs` to divert logging to `stderr` and write only the
paths of generated migration files to stdout.

Migrations
~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions tests/migrations/test_commands.py
Expand Up @@ -1528,10 +1528,10 @@ class Meta:
self.assertIn("model_name='sillymodel',", out.getvalue())
self.assertIn("name='silly_char',", out.getvalue())

def test_makemigrations_structured_output(self):
def test_makemigrations_separate_logs(self):
"""
With structured=True, logging is diverted to self.stderr, and only the paths
of generated migration files are written to self.stdout.
With separatelogs=True, logging is diverted to stderr, and only the
paths of generated migration files are written to stdout.
"""
class SillyModel(models.Model):
silly_field = models.BooleanField(default=False)
Expand All @@ -1543,7 +1543,7 @@ class Meta:
out = io.StringIO()
err = io.StringIO()
with self.temporary_migration_module(module='migrations.migrations'):
call_command('makemigrations', 'migrations', structured=True, stdout=out, stderr=err)
call_command('makemigrations', 'migrations', separatelogs=True, stdout=out, stderr=err)
self.assertIn('/migrations/0001_initial.py\n', out.getvalue())
self.assertIn(' - Create model ModelWithCustomBase\n', err.getvalue())
self.assertNotIn(' - Create model ModelWithCustomBase\n', out.getvalue())
Expand Down

0 comments on commit 4ace319

Please sign in to comment.