import functools


def skippable(*prompts, argument=None):
    """
    Decorator to allow a method on the :obj:`CustomCommand` to be
    skipped.

    Parameters:
    ----------
    prompts: :obj:iter
        A series of prompts to display to the user when the method is being
        skipped.

    argument: :obj:`str`
        By default, the management command argument to indicate that the method
        should be skipped will be `skip_<func_name>`.  If the argument should
        be different, it can be explicitly provided here.
    """
    def decorator(func):
        @functools.wraps(func)
        def inner(instance, *args, **kwargs):
            parameter = argument or "skip_%s" % func.__name__
            if parameter in kwargs and kwargs[parameter] is True:
                instance.prompt(*prompts,
                    style_func=instance.style.HTTP_NOT_MODIFIED)
                return False
            else:
                return func(instance, *args, **kwargs)
        return inner
    return decorator