From 52044e0b1603045e778461a07723419a213d9634 Mon Sep 17 00:00:00 2001 From: TheOnePath Date: Wed, 5 Jul 2023 19:01:37 +0100 Subject: [PATCH] Added help.py Added the soypak help command. When called, it will provide the user with help information about the soypak command(s) provided as arguments. - Implements a `__doc__` attribute with summar and usage. - Overrides the `run()` method from `Command` when inherited. - Inherits `command.Command` and metaclass `RegisterCommand`. --- soypak/cli/commands/help.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 soypak/cli/commands/help.py diff --git a/soypak/cli/commands/help.py b/soypak/cli/commands/help.py new file mode 100644 index 0000000..369a6c9 --- /dev/null +++ b/soypak/cli/commands/help.py @@ -0,0 +1,24 @@ +import argparse +import soypak.cli.command as command + + +class Help(command.Command, metaclass=command.RegisterCommand): + __doc__ = """Display the help message of the give command(s), or print this message. + +Usage: help [, , ..., ] +""" + + __cmd_name__ = "help" + + def __init__(self, *, data = argparse.Namespace, args: list[str] = []) -> None: + super().__init__() + self.data = data + self.rargs = args + + + def run(self): + print("running command: %s" % __name__) + print(self.data, self.rargs) + + if not self.rargs: + self.parser.print_help()