()
| 555 | |
| 556 | |
| 557 | def main(): |
| 558 | parser = argparse.ArgumentParser( |
| 559 | description="Generate bilingual content drafts and create PR from update report" |
| 560 | ) |
| 561 | parser.add_argument( |
| 562 | "--report", |
| 563 | required=True, |
| 564 | help="Path to update report JSON from fetch_updates.py --report", |
| 565 | ) |
| 566 | parser.add_argument( |
| 567 | "--dry-run", |
| 568 | action="store_true", |
| 569 | help="Preview actions without creating files or PRs", |
| 570 | ) |
| 571 | parser.add_argument( |
| 572 | "--base-branch", |
| 573 | default="main", |
| 574 | help="Base branch for the PR (default: main)", |
| 575 | ) |
| 576 | args = parser.parse_args() |
| 577 | |
| 578 | report_path = Path(args.report) |
| 579 | if not report_path.exists(): |
| 580 | print(f"ERROR: Report file not found: {report_path}") |
| 581 | sys.exit(1) |
| 582 | |
| 583 | try: |
| 584 | with open(report_path, "r", encoding="utf-8") as f: |
| 585 | report = json.load(f) |
| 586 | except Exception as e: |
| 587 | print(f"ERROR: Failed to read report: {e}") |
| 588 | sys.exit(1) |
| 589 | |
| 590 | updates_found = report.get("updates_found", 0) |
| 591 | if updates_found == 0: |
| 592 | print("No updates in report. Nothing to do.") |
| 593 | sys.exit(0) |
| 594 | |
| 595 | print(f"Report: {report.get('summary', '')}") |
| 596 | print(f"Updates: {updates_found}") |
| 597 | |
| 598 | count = process_updates(report, dry_run=args.dry_run) |
| 599 | print(f"\nDone. Processed {count} update(s).") |
| 600 | |
| 601 | |
| 602 | if __name__ == "__main__": |
no test coverage detected