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`.
This commit is contained in:
Ethan Smith-Coss 2023-07-05 19:01:37 +01:00
parent 500ddd2a77
commit 52044e0b16
Signed by: TheOnePath
GPG Key ID: 4E7D436CE1A0BAF1

View File

@ -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 [<command1>, <command2>, ..., <commandn>]
"""
__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()