diff --git a/pdfly/cli.py b/pdfly/cli.py index b258fc3..4559eed 100644 --- a/pdfly/cli.py +++ b/pdfly/cli.py @@ -283,7 +283,9 @@ def update_offsets( resolve_path=True, ), ], - file_out: Path = typer.Option(..., "-o", "--output"), # noqa + file_out: Annotated[ + Path, typer.Option("-o", "--output") # noqa + ] = None, # type: ignore encoding: str = typer.Option( "ISO-8859-1", help="Encoding used to read and write the files, e.g. UTF-8.", diff --git a/resources/file-with-invalid-offsets.pdf b/resources/file-with-invalid-offsets.pdf index b2fbc2d..75f7829 100644 Binary files a/resources/file-with-invalid-offsets.pdf and b/resources/file-with-invalid-offsets.pdf differ diff --git a/tests/test_update_offsets.py b/tests/test_update_offsets.py index c239577..6246249 100644 --- a/tests/test_update_offsets.py +++ b/tests/test_update_offsets.py @@ -14,17 +14,14 @@ def test_update_offsets(capsys, tmp_path: Path) -> None: # Arrange - input = str(RESOURCES_ROOT / "file-with-invalid-offsets.pdf") + input = RESOURCES_ROOT / "file-with-invalid-offsets.pdf" file_expected = str(RESOURCES_ROOT / "file-with-fixed-offsets.pdf") - output = tmp_path / "file-with-offsets-out.pdf" - assert not output.exists() # Act exit_code = run_cli( [ "update-offsets", str(input), - str(output), ] ) @@ -32,11 +29,10 @@ def test_update_offsets(capsys, tmp_path: Path) -> None: captured = capsys.readouterr() assert exit_code == 0, captured assert not captured.err - assert re.search(r"Wrote\s+" + re.escape(str(output)), captured.out) - assert output.exists() + assert re.search(r"Wrote\s+" + re.escape(str(input)), captured.out) with open(file_expected, encoding="iso-8859-1") as file_exp: lines_exp = file_exp.readlines() - with open(output, encoding="iso-8859-1") as file_act: + with input.open(encoding="iso-8859-1") as file_act: lines_act = file_act.readlines() assert len(lines_exp) == len( lines_act @@ -92,6 +88,7 @@ def test_update_offsets_on_all_reference_files( "--encoding", "iso-8859-1", input_pdf_filepath, + "-o", str(output_pdf_filepath), ] )