From 449fa798979214f9df1cfd4e16c3fceee2a1da84 Mon Sep 17 00:00:00 2001 From: Alister Lewis-Bowen Date: Mon, 13 Apr 2026 12:50:58 -0400 Subject: [PATCH] Fix convert.py: --global-index no longer requires --input-dir argparse validated --input-dir before the --global-index early-exit could fire, so the standalone mode always failed. Make --input-dir optional and add an explicit check for when neither flag is supplied. Fixes #24 Co-Authored-By: Claude Sonnet 4.6 --- convert.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/convert.py b/convert.py index e968d68..a043213 100644 --- a/convert.py +++ b/convert.py @@ -581,7 +581,7 @@ def main() -> None: description="Convert archive PDFs (magazines, books) to searchable Markdown" ) parser.add_argument("--analyze", action="store_true", help="Probe PDFs and report structure without converting") - parser.add_argument("--input-dir", type=Path, required=True, help="Source PDF directory") + parser.add_argument("--input-dir", type=Path, required=False, default=None, help="Source PDF directory") parser.add_argument("--output-dir", type=Path, default=Path("converted"), help="Output directory (default: ./converted)") parser.add_argument("--pattern", default="**/*.pdf", help="Glob pattern to select PDFs (default: **/*.pdf)") parser.add_argument("--dpi", type=int, default=200, help="Page image render DPI (default: 200)") @@ -604,6 +604,9 @@ def main() -> None: write_global_index(args.global_index, output_path) return + if not args.input_dir: + parser.error("--input-dir is required unless --global-index is specified") + if not args.input_dir.exists(): print(f"ERROR: Input directory not found: {args.input_dir}") sys.exit(1)