Fixed a bug in @debug (resolves issue107). Also moved @debug command to commands/default/tests.py instead.
This commit is contained in:
parent
af89dd1ef7
commit
27b7570aab
4 changed files with 73 additions and 71 deletions
|
|
@ -1,14 +1,16 @@
|
|||
"""
|
||||
This defines some test commands for use while testing the MUD.
|
||||
Just remove these commands from the default state when they
|
||||
are not needed anymore.
|
||||
This defines some test commands for use while testing the MUD and its components.
|
||||
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import IntegrityError
|
||||
from src.comms.models import Msg
|
||||
from game.gamesrc.commands.default.muxcommand import MuxCommand
|
||||
from src.permissions import permissions
|
||||
from src.utils import create
|
||||
from src.utils import debug
|
||||
from game.gamesrc.commands.default.muxcommand import MuxCommand
|
||||
|
||||
|
||||
# Test permissions
|
||||
|
||||
|
|
@ -188,3 +190,66 @@ class TestCom(MuxCommand):
|
|||
caller.msg(string)
|
||||
return
|
||||
caller.msg("Usage: @testcom/create channel")
|
||||
|
||||
|
||||
#TODO: make @debug more clever with arbitrary hooks?
|
||||
class CmdDebug(MuxCommand):
|
||||
"""
|
||||
Debug game entities
|
||||
|
||||
Usage:
|
||||
@debug[/switch] <path to code>
|
||||
|
||||
Switches:
|
||||
obj - debug an object
|
||||
script - debug a script
|
||||
|
||||
Examples:
|
||||
@debug/script game.gamesrc.scripts.myscript.MyScript
|
||||
@debug/script myscript.MyScript
|
||||
@debug/obj examples.red_button.RedButton
|
||||
|
||||
This command helps when debugging the codes of objects and scripts.
|
||||
It creates the given object and runs tests on its hooks. You can
|
||||
supply both full paths (starting from the evennia base directory),
|
||||
otherwise the system will start from the defined root directory
|
||||
for scripts and objects respectively (defined in settings file).
|
||||
|
||||
"""
|
||||
|
||||
key = "@debug"
|
||||
permissions = "cmd:debug"
|
||||
help_category = "Building"
|
||||
|
||||
def func(self):
|
||||
"Running the debug"
|
||||
|
||||
if not self.args or not self.switches:
|
||||
self.caller.msg("Usage: @debug[/obj][/script] <path>")
|
||||
return
|
||||
|
||||
path = self.args
|
||||
|
||||
if 'obj' in self.switches or 'object' in self.switches:
|
||||
# analyze path. If it starts at the evennia basedir,
|
||||
# (i.e. starts with game or src) we let it be, otherwise we
|
||||
# add a base path as defined in settings
|
||||
if path and not (path.startswith('src.') or
|
||||
path.startswith('game.')):
|
||||
path = "%s.%s" % (settings.BASE_TYPECLASS_PATH,
|
||||
path)
|
||||
|
||||
# create and debug the object
|
||||
self.caller.msg(debug.debug_object(path, self.caller))
|
||||
self.caller.msg(debug.debug_object_scripts(path, self.caller))
|
||||
|
||||
elif 'script' in self.switches:
|
||||
# analyze path. If it starts at the evennia basedir,
|
||||
# (i.e. starts with game or src) we let it be, otherwise we
|
||||
# add a base path as defined in settings
|
||||
if path and not (path.startswith('src.') or
|
||||
path.startswith('game.')):
|
||||
path = "%s.%s" % (settings.BASE_SCRIPT_PATH,
|
||||
path)
|
||||
|
||||
self.caller.msg(debug.debug_syntax_script(path))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue