summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-04-10 09:43:55 -0400
committerTim Graham <timograham@gmail.com>2014-04-10 09:43:55 -0400
commit395d75ea6bd1ee5259fd5a3b3ac1b028739a22d2 (patch)
tree61737bd9f7f4d6fddc55340aa8aaded2de544322 /django
parentb513fa5fc6f10a6e224d602bfac8f850040cef7c (diff)
Fixed #22194 -- Added --list-tags option to check command.
Thanks Elvard for the patch.
Diffstat (limited to 'django')
-rw-r--r--django/core/checks/registry.py6
-rw-r--r--django/core/management/commands/check.py7
2 files changed, 11 insertions, 2 deletions
diff --git a/django/core/checks/registry.py b/django/core/checks/registry.py
index e88e0b8c37..8217d534c6 100644
--- a/django/core/checks/registry.py
+++ b/django/core/checks/registry.py
@@ -64,8 +64,10 @@ class CheckRegistry(object):
return errors
def tag_exists(self, tag):
- tags = chain(*[check.tags for check in self.registered_checks if hasattr(check, 'tags')])
- return tag in tags
+ return tag in self.tags_available()
+
+ def tags_available(self):
+ return set(chain(*[check.tags for check in self.registered_checks if hasattr(check, 'tags')]))
registry = CheckRegistry()
diff --git a/django/core/management/commands/check.py b/django/core/management/commands/check.py
index b6d2571ab0..3532ab4fa9 100644
--- a/django/core/management/commands/check.py
+++ b/django/core/management/commands/check.py
@@ -5,6 +5,7 @@ from optparse import make_option
from django.apps import apps
from django.core import checks
+from django.core.checks.registry import registry
from django.core.management.base import BaseCommand, CommandError
@@ -16,9 +17,15 @@ class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--tag', '-t', action='append', dest='tags',
help='Run only checks labeled with given tag.'),
+ make_option('--list-tags', action='store_true', dest='list_tags',
+ help='List available tags.'),
)
def handle(self, *app_labels, **options):
+ if options.get('list_tags'):
+ self.stdout.write('\n'.join(sorted(registry.tags_available())))
+ return
+
if app_labels:
app_configs = [apps.get_app_config(app_label) for app_label in app_labels]
else: