Ticket #11745: help-categories-with-colors.patch
File help-categories-with-colors.patch, 1.5 KB (added by , 15 years ago) |
---|
-
django/core/management/__init__.py
5 5 6 6 import django 7 7 from django.core.management.base import BaseCommand, CommandError, handle_default_options 8 from django.core.management.color import color_style 8 9 from django.utils.importlib import import_module 9 10 10 11 # For backwards compatibility: get_version() used to be in this module. … … 236 237 """ 237 238 usage = ['',"Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name,''] 238 239 usage.append('Available subcommands:') 239 commands = get_commands().keys() 240 commands.sort() 241 for cmd in commands: 242 usage.append(' %s' % cmd) 240 commands_dict = {} 241 style = color_style() 242 for name, app in get_commands().iteritems(): 243 if isinstance(app, BaseCommand): 244 app = app.__module__ 245 try: 246 app = app.split('.')[0] 247 except: 248 pass 249 if app not in commands_dict: 250 commands_dict[app] = [] 251 commands_dict[app].append(name) 252 for app in sorted(commands_dict.keys()): 253 usage.append(style.NOTICE('\n[%s]' % app)) 254 for name in sorted(commands_dict[app]): 255 usage.append(' %s' % name) 243 256 return '\n'.join(usage) 244 257 245 258 def fetch_command(self, subcommand):