import click
from datetime import datetime


def validate_end_date(ctx, param, value):
    """
    Validator for the 'click' command line interface, checking whether the entered date as argument 'start_date' is
    later than argument 'end_date' and 'end_date' argument is later than current date.
    """
    # option when the user enters the '--end_date' parameter earlier than '--start_date'
    if ctx.params.get('start_date') is not None:
        if ctx.params.get('start_date') > value:
            raise click.BadParameter(f'the date value must be equal or later than: '
                                     f'{(ctx.params.get("start_date")).date()}')
    if value > datetime.now():
        raise click.BadParameter(f'the date value must be equal or earlier than {(datetime.now().date())}')
    return value