jw.pkg.cmds.lib.Cmd: Define run()

Define run(), which calls _run() in the abstract base class Cmd, not
in lib.Cmd. Otherwise lib.Cmd is not abstract, which will predictably
confuse including code outside of jw-pkg.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-09 15:04:45 +01:00
commit d50a33d9ab
2 changed files with 4 additions and 4 deletions

View file

@ -20,6 +20,3 @@ class Cmd(Base): # export
type_name_filter=r'Cmd[^.]' type_name_filter=r'Cmd[^.]'
) )
) )
async def run(self, args):
return await self._run(args)

View file

@ -64,8 +64,11 @@ class Cmd(abc.ABC): # export
def child_classes(self) -> list[type[Cmd]]: def child_classes(self) -> list[type[Cmd]]:
return tuple(self.__child_classes) return tuple(self.__child_classes)
@abc.abstractmethod
async def run(self, args): async def run(self, args):
return await self._run(args)
@abc.abstractmethod
async def _run(self, args):
pass pass
def add_subcommands(self, cmds: Cmd|list[Cmds]|Types|list[Types]) -> None: def add_subcommands(self, cmds: Cmd|list[Cmds]|Types|list[Types]) -> None: