Execute Python code with helper functions in scope.
(args: argparse.Namespace)
| 501 | |
| 502 | |
| 503 | def cmd_exec(args: argparse.Namespace) -> None: |
| 504 | """Execute Python code with helper functions in scope.""" |
| 505 | code = args.code |
| 506 | if not code: |
| 507 | print("ERROR: --code argument is required", file=sys.stderr) |
| 508 | sys.exit(1) |
| 509 | |
| 510 | exec_globals = { |
| 511 | "__builtins__": __builtins__, |
| 512 | "search": search, |
| 513 | "impl_": impl_, |
| 514 | "callers": callers, |
| 515 | "tests": tests, |
| 516 | "grep": grep, |
| 517 | "symbols": symbols, |
| 518 | "peek_file": peek_file, |
| 519 | "structure": structure, |
| 520 | "variables_list": variables_list, |
| 521 | "json": json, |
| 522 | } |
| 523 | |
| 524 | try: |
| 525 | exec(code, exec_globals) |
| 526 | except Exception as e: |
| 527 | print(f"ERROR: {type(e).__name__}: {e}", file=sys.stderr) |
| 528 | sys.exit(1) |
| 529 | |
| 530 | |
| 531 | # ── Parser ──────────────────────────────────────────────────────────── |
nothing calls this directly
no outgoing calls
no test coverage detected