def run(cls, command: str, *args: Iterable[str]):
"""
Runs the registered Command if it exists.
:raises KeyError: when the command does not exist
:param command: the registry key of the command to be invoked
:param args: the arguments to be passed on to the command
"""
if cls.has_option(command):
try:
cls.__registry[command](*args)
# except Exception as e:
# raise e
except TypeError:
print(cls.__registry[command].usage_notice())
except KeyboardInterrupt:
print("Command aborted.")
except Exception as e:
print(e)
print("Please contact support.")
else:
raise UnknownCommand(command)
评论列表
文章目录