From 7500d5424fa37ff53cb4e48ce9d9912e3db6eb95 Mon Sep 17 00:00:00 2001 From: TheOnePath Date: Sun, 30 Jul 2023 16:43:48 +0100 Subject: [PATCH] Updated help.py Added implementation to run command. For every argument give (a command), the help message for that command is displayed. Renamed `__cmd_name__` to `name`, which will be standard across all commands. --- soypak/cli/commands/help.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/soypak/cli/commands/help.py b/soypak/cli/commands/help.py index 792e4f0..5147cf4 100644 --- a/soypak/cli/commands/help.py +++ b/soypak/cli/commands/help.py @@ -6,9 +6,11 @@ class Help(command.Command, metaclass=command.RegisterCommand): __doc__ = """Display the help message of the give command(s), or print this message. Usage: help [, , ..., ] + +If no arguments are specified, the general help message is displayed. """ - __cmd_name__ = "help" + name = "help" def __init__(self, *, data: argparse.Namespace, args: list[str] = []) -> None: super().__init__() @@ -17,8 +19,13 @@ Usage: help [, , ..., ] def run(self): - print("running command: %s" % __name__) - print(self.data, self.rargs) - if not self.rargs: self.parser.print_help() + + for arg in self.rargs: + obj = self.get_command(arg, error=True) + if obj is None: + pass + + print("%s: %s" % (obj.__class__.name, obj.__doc__)) +