Execute multiple CLI commands in one invocation.
(args: argparse.Namespace)
| 382 | |
| 383 | |
| 384 | def cmd_batch(args: argparse.Namespace) -> None: |
| 385 | """Execute multiple CLI commands in one invocation.""" |
| 386 | commands = args.commands |
| 387 | lines = commands.strip().split("\n") |
| 388 | any_failed = False |
| 389 | parser = build_parser() |
| 390 | |
| 391 | for line in lines: |
| 392 | line = line.strip() |
| 393 | if not line or line.startswith("#"): |
| 394 | continue |
| 395 | print(f"=== {line} ===") |
| 396 | try: |
| 397 | tokens = shlex.split(line) |
| 398 | sub_args = parser.parse_args(tokens) |
| 399 | sub_args.func(sub_args) |
| 400 | except SystemExit as e: |
| 401 | if e.code != 0: |
| 402 | any_failed = True |
| 403 | except Exception as e: |
| 404 | print(f"ERROR: {e}", file=sys.stderr) |
| 405 | any_failed = True |
| 406 | print() |
| 407 | |
| 408 | if any_failed: |
| 409 | sys.exit(1) |
| 410 | |
| 411 | |
| 412 | # ── REPL Helper Functions (for exec --code) ────────────────────────── |
nothing calls this directly
no test coverage detected