예제 #1
0
 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))
예제 #2
0
 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)
예제 #3
0
 def test_args_okay(self):
     ConsoleCommand.check(self.test.cmd1, ())
     ConsoleCommand.check(self.test.cmd2, (1, 2))
예제 #4
0
 def test_is_a_command(self):
     ConsoleCommand.check(self.test.cmd1)
     ConsoleCommand.check(self.test.cmd2)