@classmethod
    def help_text(cls, verbose):
        def command_name(command):
            name = command
            aliases = cls.commands[command].aliases
            if aliases:
                name += ' (%s)' % ', '.join(list(aliases))
            return name

        available_other_commands = filter(
            lambda command: command in cls.commands, OTHER_COMMANDS)

        indent = 2
        max_length = max(
          len(command_name(command)) for command in itertools.chain(
              BUNDLE_COMMANDS,
              WORKSHEET_COMMANDS,
              GROUP_AND_PERMISSION_COMMANDS,
              available_other_commands)
        )

        def command_help_text(command):
            name = command_name(command)
            command_obj = cls.commands[command]

            def render_args(arguments):
                table = []
                for arg in arguments:
                    if len(arg.args) == 1:
                        table.append([arg.args[0], arg.kwargs['help']])
                    else:
                        table.append([arg.args[0] + ', ' + arg.args[1], arg.kwargs['help']])
                if len(table) == 0:
                    return []
                width = max(len(row[0]) for row in table)
                return [(' ' * (indent * 2)) + 'Arguments:'] + \
                       [(' ' * (indent * 3) + '%-' + str(width) + 's  %s') % (row[0], row[1]) for row in table] + \
                       ['']
            if verbose:
                return '%s%s:\n%s\n%s' % (
                  ' ' * indent,
                  name,
                  '\n'.join((' ' * (indent * 2)) + line for line in command_obj.help),
                  '\n'.join(render_args(command_obj.arguments))
                )
            else:
                return '%s%s%s%s' % (
                  ' ' * indent,
                  name,
                  ' ' * (indent + max_length - len(name)),
                  command_obj.help[0],
                )

        def command_group_help_text(commands):
            return '\n'.join([command_help_text(command) for command in commands])

        return textwrap.dedent("""
        Usage: cl <command> <arguments>

        Commands for bundles:
        {bundle_commands}

        Commands for worksheets:
        {worksheet_commands}

        Commands for groups and permissions:
        {group_and_permission_commands}

        Other commands:
        {other_commands}
        """).format(
            bundle_commands=command_group_help_text(BUNDLE_COMMANDS),
            worksheet_commands=command_group_help_text(WORKSHEET_COMMANDS),
            group_and_permission_commands=command_group_help_text(GROUP_AND_PERMISSION_COMMANDS),
            other_commands=command_group_help_text(available_other_commands),
        ).strip()
dataset/ETHPy150Open codalab/codalab-cli/codalab/lib/bundle_cli.py/Commands.help_text/original