[commands] Add Command.qualified_name to get the full command name.
This also sets `__str__` to do the same thing.
This commit is contained in:
@@ -306,6 +306,38 @@ class Command:
|
||||
|
||||
return result
|
||||
|
||||
@property
|
||||
def full_parent_name(self):
|
||||
"""Retrieves the fully qualified parent command name.
|
||||
|
||||
This the base command name required to execute it. For example,
|
||||
in ``?one two three`` the parent name would be ``one two``.
|
||||
"""
|
||||
entries = []
|
||||
command = self
|
||||
while command.parent is not None:
|
||||
command = command.parent
|
||||
entries.append(command.name)
|
||||
|
||||
return ' '.join(reversed(entries))
|
||||
|
||||
@property
|
||||
def qualified_name(self):
|
||||
"""Retrieves the fully qualified command name.
|
||||
|
||||
This is the full parent name with the command name as well.
|
||||
For example, in ``?one two three`` the qualified name would be
|
||||
``one two three``.
|
||||
"""
|
||||
|
||||
parent = self.full_parent_name
|
||||
if parent:
|
||||
return parent + ' ' + self.name
|
||||
else:
|
||||
return self.name
|
||||
|
||||
def __str__(self):
|
||||
return self.qualified_name
|
||||
|
||||
@asyncio.coroutine
|
||||
def _parse_arguments(self, ctx):
|
||||
|
||||
Reference in New Issue
Block a user