From a5887d23e2d93c460a101b5b3fc9e723e951c7a7 Mon Sep 17 00:00:00 2001 From: Jonathan Piacenti Date: Sat, 20 Jun 2015 13:17:06 -0500 Subject: [PATCH] Make command ambiguity handler pluggable. --- evennia/commands/cmdhandler.py | 6 ++++-- evennia/commands/cmdparser.py | 1 + evennia/server/evennia_launcher.py | 1 + evennia/settings_default.py | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/evennia/commands/cmdhandler.py b/evennia/commands/cmdhandler.py index f2d20bb1c7..1a40241ef3 100644 --- a/evennia/commands/cmdhandler.py +++ b/evennia/commands/cmdhandler.py @@ -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: diff --git a/evennia/commands/cmdparser.py b/evennia/commands/cmdparser.py index c9924f2c49..1835b6679b 100644 --- a/evennia/commands/cmdparser.py +++ b/evennia/commands/cmdparser.py @@ -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. diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index eab178b45d..21724a1aa2 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -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: diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 0165ed8238..66372d420d 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -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.