Commands now have a .cmdset_source pointing at their original cmdset instance.

This commit is contained in:
Andrew Bastien 2023-11-24 14:48:04 -05:00
parent 923ec28ec4
commit ee3705cb81
2 changed files with 4 additions and 1 deletions

View file

@ -541,6 +541,8 @@ class CmdSet(object, metaclass=_CmdSetMeta):
system_commands = self.system_commands
for cmd in cmds:
# Ensure commands know their source cmdset.
cmd.cmdset_source = self
# add all commands
if not hasattr(cmd, "obj") or cmd.obj is None:
cmd.obj = self.cmdsetobj

View file

@ -156,9 +156,10 @@ class Command(metaclass=CommandMeta):
you to know which alias was used, for example)
self.args - everything supplied to the command following the cmdstring
(this is usually what is parsed in self.parse())
self.cmdset - the cmdset from which this command was matched (useful only
self.cmdset - the merged cmdset from which this command was matched (useful only
seldomly, notably for help-type commands, to create dynamic
help entries and lists)
self.cmdset_source - the specific cmdset this command was matched from.
self.obj - the object on which this command is defined. If a default command,
this is usually the same as caller.
self.raw_string - the full raw string input, including the command name,