Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit afaf058

Browse files
authored
Merge pull request #755 from jumpstarter-dev/fix-tmt-errcode
j: return exit code properly
2 parents ec806a0 + 88241fc commit afaf058

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • packages/jumpstarter-cli/jumpstarter_cli

packages/jumpstarter-cli/jumpstarter_cli/j.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ async def cli():
2626
async with BlockingPortal() as portal:
2727
with ExitStack() as stack:
2828
async with env_async(portal, stack) as client:
29-
await to_thread.run_sync(lambda: client.cli()(standalone_mode=False))
29+
result = await to_thread.run_sync(lambda: client.cli()(standalone_mode=False))
30+
if isinstance(result, int) and result != 0:
31+
raise BaseExceptionGroup("CLI exit", [click.exceptions.Exit(result)])
3032
except BaseExceptionGroup as eg:
3133
# Handle exceptions wrapped in ExceptionGroup (e.g., from task groups)
3234
if exc := find_exception_in_group(eg, EnvironmentVariableNotSetError):
@@ -40,6 +42,9 @@ async def cli():
4042
await cli()
4143
finally:
4244
tg.cancel_scope.cancel()
45+
except* click.exceptions.Exit as excgroup:
46+
for exc in leaf_exceptions(excgroup):
47+
sys.exit(exc.exit_code)
4348
except* click.ClickException as excgroup:
4449
for exc in leaf_exceptions(excgroup):
4550
cast(click.ClickException, exc).show()

0 commit comments

Comments
 (0)