from pathlib import Path
from typing import List


def write_genome_fasta_list(
    target_dir: Path,
    list_outfile: Path,
    exts: List[str] = ["fa", "fna", ".fna.gz", "fasta"],
) -> int:
    """Write genome fasta file list for fastANI run

    Args:
        target_dir (Path): Target genome fasta directory
        list_outfile (Path): List of Genome fasta file path
        exts (List[str]): Genome fasta extension list

    Returns:
        int: Number of genome fasta files
    """
    # Get target file path list
    file_path_list = []
    for ext in exts:
        file_path_list.extend(target_dir.glob(f"*{ext}"))

    # Write file path list
    contents = "\n".join([str(f) for f in file_path_list])
    with open(list_outfile, "w") as f:
        f.write(contents)

    return len(file_path_list)