From a7b9112f0439bde3eab0a747d30e8da3bd19bb10 Mon Sep 17 00:00:00 2001 From: BlauFeuer Date: Sat, 10 Mar 2018 22:41:16 -0500 Subject: [PATCH] Suggested refactors and change to test exact match --- evennia/commands/default/muxcommand.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/evennia/commands/default/muxcommand.py b/evennia/commands/default/muxcommand.py index df49d9a215..349679f5bd 100644 --- a/evennia/commands/default/muxcommand.py +++ b/evennia/commands/default/muxcommand.py @@ -114,6 +114,8 @@ class MuxCommand(Command): # split out switches switches, delimiters = [], self.rhs_split + if self.switch_options: + self.switch_options = [opt.lower() for opt in self.switch_options] if args and len(args) > 1 and raw[0] == "/": # we have a switch, or a set of switches. These end with a space. switches = args[1:].split(None, 1) @@ -127,16 +129,16 @@ class MuxCommand(Command): if switches and self.switch_options: valid_switches, unused_switches, extra_switches = [], [], [] for element in switches: - option_check = [each for each in self.switch_options - if each.lower() == element.lower() or - each.lower().startswith(element.lower())] + option_check = [opt for opt in self.switch_options if opt == element] + if not option_check: + option_check = [opt for opt in self.switch_options if opt.startswith(element)] match_count = len(option_check) if match_count > 1: - extra_switches += option_check # Either the option provided is ambiguous, + extra_switches.extend(option_check) # Either the option provided is ambiguous, elif match_count == 1: - valid_switches += option_check # or it is a valid option abbreviation, + valid_switches.extend(option_check) # or it is a valid option abbreviation, elif match_count == 0: - unused_switches += [element] # or an extraneous option to be ignored. + unused_switches.append(element) # or an extraneous option to be ignored. if extra_switches: # User provided switches self.msg('|g%s|n: |wAmbiguous switch supplied: Did you mean /|C%s|w?' % (self.cmdstring, ' |nor /|C'.join(extra_switches)))