from pathlib import Path
import click


def validate_existing_dir(ctx, param, value: Path) -> Path:
    """
    Callback for click commands that checks that a given path is a directory
    """

    if not value.is_dir():
        raise click.BadParameter(f"{value} is not a directory")

    return value