""" JCL Runner - Main entry point. Usage: python main.py """ import sys import argparse from pathlib import Path from parser import parse_jcl from executor import Executor def main(): parser = argparse.ArgumentParser( description="JCL Runner - Execute JCL scripts on Windows" ) parser.add_argument("jcl_file", help="Path to JCL script") parser.add_argument( "--root", default=".", help="System root directory (default: current dir)", ) parser.add_argument( "--cobol-dir", default="cobol", help="COBOL source directory (relative to root)", ) parser.add_argument( "--copybook-dir", default="copybooks", help="COPYBOOK directory (relative to root)", ) args = parser.parse_args() root = Path(args.root).resolve() cobol_dir = root / args.cobol_dir copybook_dir = root / args.copybook_dir # Validate paths if not root.exists(): print(f"ERROR: Root directory not found: {root}") sys.exit(1) if not cobol_dir.exists(): print(f"ERROR: COBOL directory not found: {cobol_dir}") sys.exit(1) if not copybook_dir.exists(): print(f"ERROR: COPYBOOK directory not found: {copybook_dir}") sys.exit(1) # Parse JCL jcl_path = Path(args.jcl_file) if not jcl_path.exists(): print(f"ERROR: JCL file not found: {jcl_path}") sys.exit(1) print(f"Parsing JCL: {jcl_path}") job = parse_jcl(str(jcl_path)) if not job: print("ERROR: Failed to parse JCL (no JOB statement found)") sys.exit(1) print(f"Job: {job.job_name}, Steps: {len(job.steps)}") for i, step in enumerate(job.steps): cond_str = f" COND={step.cond}" if step.cond else "" print(f" {i+1}. {step.step_name}: EXEC PGM={step.program}{cond_str}") # Execute executor = Executor( root_dir=str(root), cobol_dir=str(cobol_dir), copybook_dir=str(copybook_dir), ) rc = executor.run(job) print(f"\nExit code: {rc}") sys.exit(rc) if __name__ == "__main__": main()