Add 'quiet' to argparsing and pass it to the linter
This commit is contained in:
1 parent
72f066e710
commit
3b8e86fdf7
2 files changed
+12
-1
No files matched your search
@@ -7,7 +7,7 @@ from django.core.management.base import BaseCommand
|
|||||||
|
|
||||||
from ...constants import __version__
|
from ...constants import __version__
|
||||||
|
|
||||||
from ...migration_linter import MigrationLinter
|
from ...migration_linter import MigrationLinter, MessageType
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@@ -102,6 +102,14 @@ class Command(BaseCommand):
|
|||||||
"to be ignored (e.g. ALTER_COLUMN)",
|
"to be ignored (e.g. ALTER_COLUMN)",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-q",
|
||||||
|
"--quiet",
|
||||||
|
nargs="+",
|
||||||
|
choices=MessageType.values(),
|
||||||
|
help="don't print linting messages to stdout",
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
if options["project_root_path"]:
|
if options["project_root_path"]:
|
||||||
settings_path = options["project_root_path"]
|
settings_path = options["project_root_path"]
|
||||||
@@ -127,6 +135,7 @@ class Command(BaseCommand):
|
|||||||
only_applied_migrations=options["applied_migrations"],
|
only_applied_migrations=options["applied_migrations"],
|
||||||
only_unapplied_migrations=options["unapplied_migrations"],
|
only_unapplied_migrations=options["unapplied_migrations"],
|
||||||
exclude_migration_tests=options["exclude_migration_tests"],
|
exclude_migration_tests=options["exclude_migration_tests"],
|
||||||
|
quiet=options["quiet"],
|
||||||
)
|
)
|
||||||
linter.lint_all_migrations(
|
linter.lint_all_migrations(
|
||||||
git_commit_id=options["commit_id"],
|
git_commit_id=options["commit_id"],
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class MigrationLinter(object):
|
|||||||
only_applied_migrations=False,
|
only_applied_migrations=False,
|
||||||
only_unapplied_migrations=False,
|
only_unapplied_migrations=False,
|
||||||
exclude_migration_tests=None,
|
exclude_migration_tests=None,
|
||||||
|
quiet=None,
|
||||||
):
|
):
|
||||||
# Store parameters and options
|
# Store parameters and options
|
||||||
self.django_path = path
|
self.django_path = path
|
||||||
@@ -74,6 +75,7 @@ class MigrationLinter(object):
|
|||||||
self.no_cache = no_cache
|
self.no_cache = no_cache
|
||||||
self.only_applied_migrations = only_applied_migrations
|
self.only_applied_migrations = only_applied_migrations
|
||||||
self.only_unapplied_migrations = only_unapplied_migrations
|
self.only_unapplied_migrations = only_unapplied_migrations
|
||||||
|
self.quiet = quiet or []
|
||||||
|
|
||||||
# Initialise counters
|
# Initialise counters
|
||||||
self.nb_valid = 0
|
self.nb_valid = 0
|
||||||
|
|||||||
Reference in new issue
Block a user