From 77bf8f4eb72511b1d3fc010fdd8e5f626b9eb1cf Mon Sep 17 00:00:00 2001 From: Andrew Bastien Date: Tue, 14 Jan 2020 09:25:45 -0500 Subject: [PATCH 1/3] Segmenting the Command methods better. --- evennia/commands/command.py | 9 +++++++++ evennia/commands/default/muxcommand.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/evennia/commands/command.py b/evennia/commands/command.py index 535ce15dd9..c99de48ac0 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -408,6 +408,15 @@ class Command(object, metaclass=CommandMeta): module for which object properties are available (beyond those set in self.parse()) + """ + self.get_command_info() + + def get_command_info(self): + """ + This is the default output of func() if no func() overload is done. + Provided here as a separate method so that it can be called for debugging + purposes when making commands. + """ variables = "\n".join( " |w{}|n ({}): {}".format(key, type(val), val) for key, val in self.__dict__.items() diff --git a/evennia/commands/default/muxcommand.py b/evennia/commands/default/muxcommand.py index d288f5f980..797dd6e39d 100644 --- a/evennia/commands/default/muxcommand.py +++ b/evennia/commands/default/muxcommand.py @@ -208,6 +208,12 @@ class MuxCommand(Command): by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein. """ + self.get_command_info() + + def get_command_info(self): + """ + Update of parent class's get_command_info() for MuxCommand. + """ variables = "\n".join( " |w{}|n ({}): {}".format(key, type(val), val) for key, val in self.__dict__.items() ) From 597a0dbee2a59b19830c3e9b2ccdf79360524dd2 Mon Sep 17 00:00:00 2001 From: Andrew Bastien Date: Tue, 14 Jan 2020 09:25:45 -0500 Subject: [PATCH 2/3] Segmenting the Command methods better. --- evennia/commands/command.py | 9 +++++++++ evennia/commands/default/muxcommand.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/evennia/commands/command.py b/evennia/commands/command.py index 535ce15dd9..c99de48ac0 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -408,6 +408,15 @@ class Command(object, metaclass=CommandMeta): module for which object properties are available (beyond those set in self.parse()) + """ + self.get_command_info() + + def get_command_info(self): + """ + This is the default output of func() if no func() overload is done. + Provided here as a separate method so that it can be called for debugging + purposes when making commands. + """ variables = "\n".join( " |w{}|n ({}): {}".format(key, type(val), val) for key, val in self.__dict__.items() diff --git a/evennia/commands/default/muxcommand.py b/evennia/commands/default/muxcommand.py index d288f5f980..797dd6e39d 100644 --- a/evennia/commands/default/muxcommand.py +++ b/evennia/commands/default/muxcommand.py @@ -208,6 +208,12 @@ class MuxCommand(Command): by the cmdhandler right after self.parser() finishes, and so has access to all the variables defined therein. """ + self.get_command_info() + + def get_command_info(self): + """ + Update of parent class's get_command_info() for MuxCommand. + """ variables = "\n".join( " |w{}|n ({}): {}".format(key, type(val), val) for key, val in self.__dict__.items() ) From 532c509a9e6df2d137fcf1b848d14167d77788a9 Mon Sep 17 00:00:00 2001 From: Andrew Bastien Date: Fri, 17 Jan 2020 18:06:43 -0500 Subject: [PATCH 3/3] Doing requested changes. Moving func() and get_command_info(), updating CHANGELOG.md --- CHANGELOG.md | 3 +++ evennia/commands/command.py | 20 ++++++++++---------- evennia/commands/default/muxcommand.py | 16 ++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6ca4e3d4..eb5e02c79a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ ### Already in master +- Moved behavior of default `Command` and `MuxCommand` `.func()` to new `.get_command_info()` +method so the debug info can be called even if `.func()` is overloaded. `.func()` now calls +this new method by default. (Volund) - `py` command now reroutes stdout to output results in-game client. `py` without arguments starts a full interactive Python console. - Webclient default to a single input pane instead of two. Now defaults to no help-popup. diff --git a/evennia/commands/command.py b/evennia/commands/command.py index c99de48ac0..6ff992eee0 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -401,16 +401,6 @@ class Command(object, metaclass=CommandMeta): """ pass - def func(self): - """ - This is the actual executing part of the command. It is - called directly after self.parse(). See the docstring of this - module for which object properties are available (beyond those - set in self.parse()) - - """ - self.get_command_info() - def get_command_info(self): """ This is the default output of func() if no func() overload is done. @@ -447,6 +437,16 @@ Command {self} has no defined `func()` - showing on-command variables: self.caller.msg(string) + def func(self): + """ + This is the actual executing part of the command. It is + called directly after self.parse(). See the docstring of this + module for which object properties are available (beyond those + set in self.parse()) + + """ + self.get_command_info() + def get_extra_info(self, caller, **kwargs): """ Display some extra information that may help distinguish this diff --git a/evennia/commands/default/muxcommand.py b/evennia/commands/default/muxcommand.py index 797dd6e39d..e7eee50992 100644 --- a/evennia/commands/default/muxcommand.py +++ b/evennia/commands/default/muxcommand.py @@ -202,14 +202,6 @@ class MuxCommand(Command): else: self.character = None - def func(self): - """ - This is the hook function that actually does all the work. It is called - by the cmdhandler right after self.parser() finishes, and so has access - to all the variables defined therein. - """ - self.get_command_info() - def get_command_info(self): """ Update of parent class's get_command_info() for MuxCommand. @@ -251,6 +243,14 @@ Command {self} has no defined `func()` - showing on-command variables: No child string += "-" * 50 self.caller.msg(string) + def func(self): + """ + This is the hook function that actually does all the work. It is called + by the cmdhandler right after self.parser() finishes, and so has access + to all the variables defined therein. + """ + self.get_command_info() + class MuxAccountCommand(MuxCommand): """