Skip to content

Commit 55c9e12

Browse files
committed
Modified get_names() method to allow dynamically adding do_* commands to instances at runtime
1 parent 3709be4 commit 55c9e12

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cmd2/cmd2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,10 @@ def _autocomplete_default(self, text: str, line: str, begidx: int, endidx: int,
15961596
tokens, _ = self.tokens_for_completion(line, begidx, endidx)
15971597
return completer.complete_command(tokens, text, line, begidx, endidx)
15981598

1599+
def get_names(self):
1600+
"""Return an alphabetized list of names comprising the attributes of the cmd2 class instance."""
1601+
return dir(self)
1602+
15991603
def get_all_commands(self) -> List[str]:
16001604
"""Return a list of all commands"""
16011605
return [name[len(COMMAND_FUNC_PREFIX):] for name in self.get_names()

0 commit comments

Comments
 (0)