'Returns the script\'s main help text, as a string.'

def main_help_text(self, commands_only=False):

    if commands_only:
        usage = sorted(get_commands().keys())
    else:
        usage = ['', ("Type    '%s    help    <subcommand>'    for    help    on    a    specific    subcommand." % self.prog_name), '', 'Available    subcommands:']
        commands_dict = collections.defaultdict((lambda : []))
        for (name, app) in six.iteritems(get_commands()):
            if (app == 'django.core'):
                app = 'django'
            else:
                app = app.rpartition('.')[(-1)]
            commands_dict[app].append(name)
        style = color_style()
        for app in sorted(commands_dict.keys()):
            usage.append('')
            usage.append(style.NOTICE(('[%s]' % app)))
            for name in sorted(commands_dict[app]):
                usage.append(('                %s' % name))
    return '\n'.join(usage)
