def help(self, command): """Show a help message about a command.""" try: f = self.__getattribute__(command) except AttributeError: self.system_message("No such command.") try: ConsoleCommand.check(f) except ConsoleCommand.NotACommand: self.system_message("No such command.") self.system_message(ConsoleCommand.help_message(f))
def execute_command(self, name, *args): """Execute a console command.""" try: f = self.__getattribute__(name) except AttributeError: self.system_message("No such command.") return try: ConsoleCommand.check(f, args) except ConsoleCommand.NotACommand: self.system_message("No such command.") return except ConsoleCommand.ArgsMismatch: self.system_message("Invalid command arguments provided.") return f(*args)
def test_args_okay(self): ConsoleCommand.check(self.test.cmd1, ()) ConsoleCommand.check(self.test.cmd2, (1, 2))
def test_is_a_command(self): ConsoleCommand.check(self.test.cmd1) ConsoleCommand.check(self.test.cmd2)