mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 17:56:32 +01:00
Added arg_regex, an optional Command class-method for customizing how commands are identified by using a regex to enforce a specific look/grammar to the command argument. Discussed and suggested in issue 213.
This commit is contained in:
parent
42254fa3c4
commit
690bfadd9d
4 changed files with 13 additions and 3 deletions
|
|
@ -47,9 +47,11 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
|
|||
l_raw_string = raw_string.lower()
|
||||
for cmd in cmdset:
|
||||
matches.extend([create_match(cmdname, raw_string, cmd)
|
||||
for cmdname in [cmd.key] + cmd.aliases
|
||||
if cmdname and l_raw_string.startswith(cmdname.lower())])
|
||||
if not matches:
|
||||
for cmdname in [cmd.key] + cmd.aliases
|
||||
if cmdname and l_raw_string.startswith(cmdname.lower())
|
||||
and (not cmd.arg_regex or
|
||||
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
|
||||
if not matches:
|
||||
# no matches found.
|
||||
if '-' in raw_string:
|
||||
# This could be due to the user trying to identify the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue