import six
import functools


def command_aware_wraps(f):
    """
    Decorator passing the command attribute of the wrapped function to the wrapper

    This needs to be used by decorators that are trying to wrap clicmd decorated command functions.
    """
    additional = ()
    if hasattr(f, 'command'):
        additional = ('command',)
    return six.wraps(f, assigned=functools.WRAPPER_ASSIGNMENTS + additional)