From 8db12deaff67d0dd8ab9261a3570d9a3233cb20a Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 5 Mar 2024 17:31:56 +0100 Subject: [PATCH] cli (base): fix exit code transmission when `SystemExit` is catched. --- libervia/cli/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libervia/cli/base.py b/libervia/cli/base.py index 2c49b842..cb84d673 100644 --- a/libervia/cli/base.py +++ b/libervia/cli/base.py @@ -734,10 +734,10 @@ class LiberviaCli: self.loop = LiberviaCLILoop() try: self.loop.run(self, args, namespace) - except SystemExit: + except SystemExit as e: # The loop is stopped, but we execute it one more time to call `a_quit` which # will call any cleaning method including async ones. - asyncio.get_event_loop().run_until_complete(self.a_quit()) + asyncio.get_event_loop().run_until_complete(self.a_quit(e.code)) @classmethod def run(cls): @@ -804,7 +804,7 @@ class LiberviaCli: if raise_exc: raise QuitException - async def a_quit(self, exit_code=0, raise_exc=True): + async def a_quit(self, exit_code: int=0, raise_exc=True): """Execute async quit callback before actually quitting This method should be prefered to ``quit``, as it executes async quit callbacks