import typer
from typing_extensions import Annotated

from texmemo.exporter import Exporter

app = typer.Typer()


def export(
    input: Annotated[str, typer.Argument(
        help="Path to input .tex file or to its parent folder"
    )],
    output: Annotated[str, typer.Argument(
        help="Output CSV file path"
    )],
    tag: Annotated[bool, typer.Option(
        "--tag", "-t", help="Include tag field by section"
    )] = False,
    header: Annotated[bool, typer.Option(
        "--header", "-H", help="Include header row"
    )] = False,
    delimiter: Annotated[str, typer.Option(
        "--delimiter", "-d", help="Delimiter for CSV. Default to ;"
    )] = ';',
    strict_mode: Annotated[bool, typer.Option(
        "--strict-mode", "-s", help="Do not tolerate invalid .tex input."
    )] = False,
    force: Annotated[bool, typer.Option(
        "--force", "-f", help="Overwrite existing file."
    )] = False
):
    exporter = Exporter()
    exporter.export(input, output, tag, header,
                    delimiter, strict_mode, True, force)
