import click


def require_value_callback(valid_options=None):
    """ Raise exception if input is not supplied.
    :param tuple|None valid_options: valid options for the parameter. If None, anything goes
    """
    def callback(ctx, param, value):
        if value is None:
            raise click.BadParameter("you must supply " + param.name)
        elif valid_options is not None and value not in valid_options:
            raise click.BadParameter("value must be one of %s" % str(valid_options))
        return value
    return callback