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.
This commit is contained in:
Ethan Smith-Coss 2023-07-30 16:43:48 +01:00
parent d7a2aa489b
commit 7500d5424f
Signed by: TheOnePath
GPG Key ID: 4E7D436CE1A0BAF1

View File

@ -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. __doc__ = """Display the help message of the give command(s), or print this message.
Usage: help [<command1>, <command2>, ..., <commandn>] Usage: help [<command1>, <command2>, ..., <commandn>]
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: def __init__(self, *, data: argparse.Namespace, args: list[str] = []) -> None:
super().__init__() super().__init__()
@ -17,8 +19,13 @@ Usage: help [<command1>, <command2>, ..., <commandn>]
def run(self): def run(self):
print("running command: %s" % __name__)
print(self.data, self.rargs)
if not self.rargs: if not self.rargs:
self.parser.print_help() 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__))