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:
parent
500ddd2a77
commit
52044e0b16
24
soypak/cli/commands/help.py
Normal file
24
soypak/cli/commands/help.py
Normal 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()
|
||||
Loading…
Reference in New Issue
Block a user