Run a delegated CLI command callable, translating its exit into errors.
(action: str, label: str, call)
| 97 | |
| 98 | |
| 99 | def _delegate_command(action: str, label: str, call) -> None: |
| 100 | """Run a delegated CLI command callable, translating its exit into errors.""" |
| 101 | import typer |
| 102 | |
| 103 | try: |
| 104 | call() |
| 105 | except typer.Exit as exc: # raised by the delegated command on failure |
| 106 | code = getattr(exc, "exit_code", 0) or 0 |
| 107 | if code != 0: |
| 108 | raise BundlerError(f"Failed to {action} {label}.") from exc |
| 109 | except SystemExit as exc: # pragma: no cover - defensive |
| 110 | if exc.code not in (0, None): |
| 111 | raise BundlerError(f"Failed to {action} {label}.") from exc |
| 112 | |
| 113 | |
| 114 | class _PresetKindManager: |
no test coverage detected