Display human-readable errors when the markdown file, photo, or signature cannot be found instead of failing with a stack trace. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
32 lines
903 B
Python
32 lines
903 B
Python
from pathlib import Path
|
|
|
|
import typer
|
|
|
|
from cv_generator.generator import generate_pdf
|
|
|
|
app = typer.Typer()
|
|
|
|
|
|
@app.command()
|
|
def generate(
|
|
input_file: Path = typer.Argument(help="Markdown file with YAML frontmatter"), # pyright: ignore[reportCallInDefaultInitializer]
|
|
output_file: Path | None = typer.Option( # pyright: ignore[reportCallInDefaultInitializer]
|
|
None, "--output", "-o", help="Output PDF path"
|
|
),
|
|
) -> None:
|
|
"""Generate a PDF CV from a Markdown file with YAML frontmatter."""
|
|
if not input_file.exists():
|
|
typer.echo(f"Error: Markdown file not found: {input_file}", err=True)
|
|
raise typer.Exit(1)
|
|
|
|
try:
|
|
result = generate_pdf(input_file, output_file)
|
|
except FileNotFoundError as e:
|
|
typer.echo(f"Error: {e}", err=True)
|
|
raise typer.Exit(1)
|
|
|
|
typer.echo(f"Generated {result}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app()
|