#!/usr/bin/env python3
# -S uv run --with ebooklib>=0.18.0 --script
# /// script
# dependencies = [
#   "click>=8.1.3",
#   "ebooklib>=0.18.0",
#   "epub2audio>=0.1.0",
# ]
# ///
#MISE alias="read-epub"
#MISE description="Read a EPUB file"
"""Read a EPUB file."""

from pathlib import Path

import click
import ebooklib  # type: ignore
from ebooklib import epub

from epub2audio import EpubProcessor



@click.command()
@click.argument("path", type=click.Path(exists=True))
def read_epub(path: Path) -> epub.EpubBook:
    """Read a EPUB file carefully.

    Meant to be used for debugging.

    Args:
        path: Path to the EPUB file

    Returns:
        epub.EpubBook: The EPUB book
    """
    # epub_processor = EpubProcesss
    # Read a new EPUB book
    book = epub.read_epub(path)

    print(book.get_items_of_type(ebooklib.ITEM_DOCUMENT))
    from code import interact; interact(local=locals())

if __name__ == "__main__":
    read_epub()
