mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 05:57:16 +02:00
Added auto_help as a class property on Commands. This allows to turn on/off auto-help generation on a per-command basis (default is on).
This commit is contained in:
parent
6a78fdafcb
commit
aae67225a4
2 changed files with 12 additions and 6 deletions
|
|
@ -47,9 +47,10 @@ class CommandMeta(type):
|
|||
mcs.arg_regex = re.compile(r"%s" % mcs.arg_regex, re.I)
|
||||
else:
|
||||
mcs.arg_regex = None
|
||||
|
||||
if not hasattr(mcs, "auto_help"):
|
||||
mcs.auto_help = True
|
||||
if not hasattr(mcs, 'is_exit'):
|
||||
mcs.is_exit = False
|
||||
mcs.is_exit = False
|
||||
if not hasattr(mcs, "help_category"):
|
||||
mcs.help_category = "general"
|
||||
mcs.help_category = mcs.help_category.lower()
|
||||
|
|
@ -99,10 +100,15 @@ class Command(object):
|
|||
locks = ""
|
||||
# used by the help system to group commands in lists.
|
||||
help_category = "general"
|
||||
|
||||
# this normally does not need to be changed. It allows to turn off
|
||||
# auto-help entry creation for individual commands.
|
||||
auto_help = True
|
||||
# There is also the property 'obj'. This gets set by the system
|
||||
# on the fly to tie this particular command to a certain in-game entity.
|
||||
# self.obj should NOT be defined here since it will not be overwritten
|
||||
# if it already exists.
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.lockhandler = LockHandler(self)
|
||||
|
|
|
|||
|
|
@ -92,13 +92,13 @@ class CmdHelp(Command):
|
|||
# having to allow doublet commands to manage exits etc.
|
||||
cmdset.make_unique(caller)
|
||||
|
||||
# Listing help entries
|
||||
# Listing all help entries
|
||||
|
||||
if query in LIST_ARGS:
|
||||
# we want to list all available help entries, grouped by category.
|
||||
hdict_cmd = {}
|
||||
for cmd in (cmd for cmd in cmdset if cmd.access(caller)
|
||||
if not cmd.key.startswith('__') and not cmd.is_exit):
|
||||
for cmd in (cmd for cmd in cmdset if cmd.auto_help and not cmd.is_exit
|
||||
and not cmd.key.startswith('__') and cmd.access(caller)):
|
||||
try:
|
||||
hdict_cmd[cmd.help_category].append(cmd.key)
|
||||
except KeyError:
|
||||
|
|
@ -117,7 +117,7 @@ class CmdHelp(Command):
|
|||
# Look for a particular help entry
|
||||
|
||||
# Cmd auto-help dynamic entries
|
||||
cmdmatches = [cmd for cmd in cmdset if query in cmd and cmd.access(caller)]
|
||||
cmdmatches = [cmd for cmd in cmdset if query in cmd and cmd.auto_help and cmd.access(caller)]
|
||||
if len(cmdmatches) > 1:
|
||||
# multiple matches. Try to limit it down to exact match
|
||||
cmdmatches = [cmd for cmd in cmdmatches if cmd == query] or cmdmatches
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue