Skip to content

Commit 6e41748

Browse files
committed
Fix CLI return code
Click does the work, and doesn't care about return values. Also, we don't stop processing when one document fails, so we can see all problems not just one. So we need to error out if any of the documents failed.
1 parent af97e51 commit 6e41748

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/pdfbaker/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def bake(
5656
keep_build=keep_build,
5757
)
5858
baker = PDFBaker(config_file, options=options)
59-
baker.bake()
60-
return 0
59+
success = baker.bake()
60+
sys.exit(0 if success else 1)
6161
except PDFBakerError as exc:
6262
logger.error(str(exc))
63-
return 1
63+
sys.exit(1)
6464

6565

6666
if __name__ == "__main__":
67-
sys.exit(cli())
67+
cli()

src/pdfbaker/baker.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ def __init__(
110110
)
111111

112112
def bake(self) -> None:
113-
"""Create PDFs for all documents."""
113+
"""Create PDFs for all documents.
114+
115+
Returns:
116+
bool: True if all documents were processed successfully, False if any failed
117+
"""
114118
pdfs_created: list[Path] = []
115119
failed_docs: list[tuple[str, str]] = []
116120

@@ -156,6 +160,8 @@ def bake(self) -> None:
156160
if not self.keep_build:
157161
self.teardown()
158162

163+
return not failed_docs
164+
159165
def teardown(self) -> None:
160166
"""Clean up (top-level) build directory after processing."""
161167
self.log_debug_subsection(

0 commit comments

Comments
 (0)