Fixed most input validation bugs, and did too many improvements to remember. Did I mention that I am typing these words with my hands?

This commit is contained in:
Patrick Marsee 2020-05-10 23:26:21 -04:00
parent ee5c4da549
commit 4a398cc2a3
11 changed files with 546 additions and 253 deletions

View file

@ -133,7 +133,10 @@ class Shell(object):
self.__exit = False
def man(self, args):
help(self.__commands[args[0]])
if (len(args)):
help(self.__commands[args[0]])
else:
print("Usage: help <commamd>\nCommands:\n\t{}".format('\n\t'.join(list(self.__commands.keys()))))
def registerCommand(self, commandName: str, command: _types.FunctionType):
"""command must be a function that takes one argument: a list of strings,
@ -288,10 +291,10 @@ $>=0 - $>=n is the nth and later arguments"""
else:
self.handleUnknownCommand(command)
def handleUnknownCommand(self, command):
def handleUnknownCommand(self, command: list):
"""Handle commands that aren't registered. Override this if you want to do
something with those commands."""
print("Bad command.")
print(f"Unknown command: {' '.join(command)}")
def update(self):
"""Runs at the end of each loop. Does nothing by default. Override this if