Merge pull request #3342 from volundmush/cmdset_source

Add Command.cmdset_source
This commit is contained in:
Griatch 2023-12-02 18:58:12 +01:00 committed by GitHub
commit 4857f93824
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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,