Looking through our command code after a long hiatus, I realized that it was pretty much awful. So here's part 1 of the command interpreter overhaul.

- The command handler has been drastically simplified. We were doing way too much processing in the handler that should have been done in the individual command functions themselves.
- The 'cdat' dict we were previously passing around has been replaced with a Command object that has useful methods for performing some of the parsing command functions will probably want to do from time to time.
- All commands were updated to use the new Command object, tested, and cleaned up in general.
- A lot of formatting was cleaned up.
- A lot of previously un-found bugs and limitations were fixed.
- The 'page' command has been broken out into its own file, since it's going to have a number of functions that would otherwise clutter commands/general.py.

Expect a commit (probably later today) that will clean up the second half of cmdhandler.py.
This commit is contained in:
Greg Taylor 2008-12-14 20:21:02 +00:00
parent 37d66093cc
commit d58f4eb517
16 changed files with 818 additions and 698 deletions

View file

@ -74,13 +74,20 @@ class SessionProtocol(StatefulTelnetProtocol):
Any line return indicates a command for the purpose of a MUD. So we take
the user input and pass it to our command handler.
"""
# Clean up the input.
line = (''.join(data))
line = line.strip('\r')
uinput = line
# Stuff anything we need to pass in this dictionary.
cdat = {"server": self.factory.server, "uinput": uinput, "session": self}
cmdhandler.handle(cdat)
# The Command object has all of the methods for parsing and preparing
# for searching and execution.
command = cmdhandler.Command(uinput,
server=self.factory.server,
session=self)
# Send the command object to the command handler for parsing
# and eventual execution.
cmdhandler.handle(command)
def execute_cmd(self, cmdstr):
"""