From 2d793c7958f6d68eaafada53a8bab15d7960877d Mon Sep 17 00:00:00 2001 From: Eric Mendes Date: Thu, 15 Jan 2026 02:04:51 +0000 Subject: [PATCH] refactor(cli): added file_parser mutually exclusive group --- run_pageindex.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/run_pageindex.py b/run_pageindex.py index 107024505..211f4fb1b 100644 --- a/run_pageindex.py +++ b/run_pageindex.py @@ -7,8 +7,11 @@ if __name__ == "__main__": # Set up argument parser parser = argparse.ArgumentParser(description='Process PDF or Markdown document and generate structure') - parser.add_argument('--pdf_path', type=str, help='Path to the PDF file') - parser.add_argument('--md_path', type=str, help='Path to the Markdown file') + + # Validate that exactly one file type is specified + file_parser = parser.add_mutually_exclusive_group(required=True) + file_parser.add_argument('--pdf_path', type=str, help='Path to the PDF file') + file_parser.add_argument('--md_path', type=str, help='Path to the Markdown file') parser.add_argument('--model', type=str, default='gpt-4o-2024-11-20', help='Model to use') @@ -37,12 +40,6 @@ help='Token threshold for generating summaries (markdown only)') args = parser.parse_args() - # Validate that exactly one file type is specified - if not args.pdf_path and not args.md_path: - raise ValueError("Either --pdf_path or --md_path must be specified") - if args.pdf_path and args.md_path: - raise ValueError("Only one of --pdf_path or --md_path can be specified") - if args.pdf_path: # Validate PDF file if not args.pdf_path.lower().endswith('.pdf'):