diff --git a/src/python/jw/pkg/lib/Cmd.py b/src/python/jw/pkg/lib/Cmd.py index a5cdf489..ccdbf44b 100644 --- a/src/python/jw/pkg/lib/Cmd.py +++ b/src/python/jw/pkg/lib/Cmd.py @@ -21,8 +21,10 @@ class Cmd(abc.ABC): # export self.__children: list[Cmd] = [] self.__child_classes: list[type[Cmd]] = [] - async def _run(self, args): - pass + @abc.abstractmethod + async def _run(self, args) -> None: + if isinstance(self.__parent, Cmd): # Calling App.run() would loop + return await self.__parent._run(args) def set_parent(self, parent: Any|Cmd): self.__parent = parent @@ -67,10 +69,6 @@ class Cmd(abc.ABC): # export async def run(self, args): return await self._run(args) - @abc.abstractmethod - async def _run(self, args): - pass - def add_subcommands(self, cmds: Cmd|list[Cmds]|Types|list[Types]) -> None: if isinstance(cmds, Cmd): assert False