lib.Cmd.print_help(): Add method

Add Cmd.print_help(). By default, it prints a help message. If passed an integer exit_status, it also calls sys.exit(exit_status).

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-05-01 10:17:38 +02:00
commit 30abb227c7
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
2 changed files with 6 additions and 3 deletions

View file

@ -80,6 +80,11 @@ class Cmd(abc.ABC): # export
def child_classes(self) -> list[type[Cmd]]:
return tuple(self.__child_classes)
def print_help(self, exit_status: int|None=None) -> None:
self.parser.print_help()
if exit_status is not None:
sys.exit(exit_status)
async def run(self, args):
return await self._run(args)