def get_formatter(columns):
    """This function returns a callback to use with click options.

    The retuend function parses a comma-separated value and returns a new
    ColumnFormatter.

    :param columns: a list of Column instances
    """

    column_map = dict((column.name, column) for column in columns)

    def validate(ctx, param, value):
        """Click validation function."""
        if value == '':
            raise click.BadParameter('At least one column is required.')

        formatter = ColumnFormatter()
        for column in [col.strip() for col in value.split(',')]:
            if column in column_map:
                formatter.add_column(column_map[column])
            else:
                formatter.add_column(Column(column, column.split('.')))

        return formatter

    return validate
dataset/ETHPy150Open softlayer/softlayer-python/SoftLayer/CLI/columns.py/get_formatter/original