コード例 #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_help_message(self):
     ConsoleCommand.help_message(self.test.cmd1)
     ConsoleCommand.help_message(self.test.cmd2)
コード例 #5
0
 def test_is_a_command(self):
     ConsoleCommand.check(self.test.cmd1)
     ConsoleCommand.check(self.test.cmd2)