Make command ambiguity handler pluggable.

This commit is contained in:
Jonathan Piacenti 2015-06-20 13:17:06 -05:00
parent f116543e14
commit a5887d23e2
4 changed files with 9 additions and 2 deletions

View file

@ -42,7 +42,6 @@ from twisted.internet.defer import inlineCallbacks, returnValue
from django.conf import settings
from evennia.comms.channelhandler import CHANNELHANDLER
from evennia.utils import logger, utils
from evennia.commands.cmdparser import at_multimatch_cmd
from evennia.utils.utils import string_suggestions, to_unicode
from django.utils.translation import ugettext as _
@ -71,6 +70,9 @@ CMD_CHANNEL = "__send_to_channel_command"
# (is expected to display the login screen)
CMD_LOGINSTART = "__unloggedin_look_command"
# Function for handling multiple command matches.
_AT_MULTIMATCH_CMD = utils.variable_from_module(*settings.SEARCH_AT_MULTIMATCH_CMD.rsplit('.', 1))
# Output strings
_ERROR_UNTRAPPED = "{traceback}\n" \
@ -486,7 +488,7 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess
syscmd.matches = matches
else:
# fall back to default error handling
sysarg = yield at_multimatch_cmd(caller, matches)
sysarg = yield _AT_MULTIMATCH_CMD(caller, matches)
raise ExecSystemCommand(syscmd, sysarg)
if len(matches) == 1:

View file

@ -137,6 +137,7 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
#
# SEARCH_AT_RESULT
# SEARCH_AT_MULTIMATCH_INPUT
# SEARCH_AT_MULTIMATCH_CMD
#
# The the replacing functions must have the same inputs and outputs as
# those in this module.

View file

@ -611,6 +611,7 @@ def error_check_python_modules():
imp(settings.COMMAND_PARSER)
imp(settings.SEARCH_AT_RESULT)
imp(settings.SEARCH_AT_MULTIMATCH_INPUT)
imp(settings.SEARCH_AT_MULTIMATCH_CMD)
imp(settings.CONNECTION_SCREEN_MODULE)
#imp(settings.AT_INITIAL_SETUP_HOOK_MODULE, split=False)
for path in settings.LOCK_FUNC_MODULES:

View file

@ -240,6 +240,9 @@ SEARCH_AT_RESULT = "evennia.commands.cmdparser.at_search_result"
# object matches (so you can separate between same-named
# objects without using dbrefs).
SEARCH_AT_MULTIMATCH_INPUT = "evennia.commands.cmdparser.at_multimatch_input"
# The parser used in order to separate multiple
# command matches (so you can separate between same-named commands)
SEARCH_AT_MULTIMATCH_CMD = "evennia.commands.cmdparser.at_multimatch_cmd"
# The module holding text strings for the connection screen.
# This module should contain one or more variables
# with strings defining the look of the screen.