from pathlib import Path


def find_config_file(src: Path) -> Path:
    """Look for sniptly.toml config file

    Args:
        src (Path): File or folder where to look for sniptly snippets.

    Raises:
        FileNotFoundError

    Returns:
        Path: Path to tohe config file.
    """
    parents = src.resolve().parents
    paths_to_search_in = [src] + list(parents) if src.is_dir() else parents
    for path in paths_to_search_in:
        if (path / "sniptly.toml").exists():
            return path / "sniptly.toml"
    raise FileNotFoundError(
        f"Config file was not found. Looked in {str(paths_to_search_in)}"
    )