import functools
import time
import click


def timer(function):
    """
    Timer decorator for return a functions execution in seconds.

    Args:
        function: function to be timed

    Returns: time taken plus the original function executed.

    """

    @functools.wraps(function)
    def wrapper(*args, **kwargs):
        t1 = time.time()
        result = function(*args, **kwargs)
        click.echo(f"Download completed in {time.time() - t1:.2f} seconds")
        return result

    return wrapper